Use "final" and "override" where appropriate (#117)

This commit is contained in:
Tony Wasserka 2018-06-03 05:46:27 +00:00 committed by SciresM
parent bb636dc05a
commit edc099f026
14 changed files with 67 additions and 67 deletions

View file

@ -4,8 +4,8 @@
#include "ipc_templating.hpp" #include "ipc_templating.hpp"
class IServiceObject { class IServiceObject {
public: protected:
virtual ~IServiceObject() { } virtual ~IServiceObject() { }
virtual Result dispatch(IpcParsedCommand &r, IpcCommand &out_c, u64 cmd_id, u8 *pointer_buffer, size_t pointer_buffer_size) = 0; virtual Result dispatch(IpcParsedCommand &r, IpcCommand &out_c, u64 cmd_id, u8 *pointer_buffer, size_t pointer_buffer_size) = 0;
virtual Result handle_deferred() = 0; virtual Result handle_deferred() = 0;
}; };

View file

@ -23,7 +23,7 @@ template <typename T>
class IServer; class IServer;
template <typename T> template <typename T>
class ServiceSession : public IWaitable { class ServiceSession final : public IWaitable {
static_assert(std::is_base_of<IServiceObject, T>::value, "Service Objects must derive from IServiceObject"); static_assert(std::is_base_of<IServiceObject, T>::value, "Service Objects must derive from IServiceObject");
T *service_object; T *service_object;
@ -39,7 +39,7 @@ class ServiceSession : public IWaitable {
this->service_object = new T(); this->service_object = new T();
} }
virtual ~ServiceSession() { ~ServiceSession() override {
delete this->service_object; delete this->service_object;
if (server_handle) { if (server_handle) {
svcCloseHandle(server_handle); svcCloseHandle(server_handle);
@ -54,23 +54,23 @@ class ServiceSession : public IWaitable {
Handle get_client_handle() { return this->client_handle; } Handle get_client_handle() { return this->client_handle; }
/* IWaitable */ /* IWaitable */
virtual unsigned int get_num_waitables() { unsigned int get_num_waitables() override {
return 1; return 1;
} }
virtual void get_waitables(IWaitable **dst) { void get_waitables(IWaitable **dst) override {
dst[0] = this; dst[0] = this;
} }
virtual void delete_child(IWaitable *child) { void delete_child(IWaitable *child) override {
/* TODO: Panic, because we can never have any children. */ /* TODO: Panic, because we can never have any children. */
} }
virtual Handle get_handle() { Handle get_handle() override {
return this->server_handle; return this->server_handle;
} }
virtual void handle_deferred() { void handle_deferred() override {
Result rc = this->service_object->handle_deferred(); Result rc = this->service_object->handle_deferred();
int handle_index; int handle_index;
@ -84,7 +84,7 @@ class ServiceSession : public IWaitable {
} }
} }
virtual Result handle_signaled(u64 timeout) { Result handle_signaled(u64 timeout) override {
Result rc; Result rc;
int handle_index; int handle_index;

View file

@ -7,7 +7,7 @@
#define SYSTEMEVENT_INDEX_WAITHANDLE 0 #define SYSTEMEVENT_INDEX_WAITHANDLE 0
#define SYSTEMEVENT_INDEX_SGNLHANDLE 1 #define SYSTEMEVENT_INDEX_SGNLHANDLE 1
class SystemEvent : public IEvent { class SystemEvent final : public IEvent {
public: public:
SystemEvent(EventCallback callback) : IEvent(0, callback) { SystemEvent(EventCallback callback) : IEvent(0, callback) {
Handle wait_h; Handle wait_h;
@ -20,7 +20,7 @@ class SystemEvent : public IEvent {
this->handles.push_back(sig_h); this->handles.push_back(sig_h);
} }
virtual Result signal_event() { Result signal_event() override {
return svcSignalEvent(this->handles[SYSTEMEVENT_INDEX_SGNLHANDLE]); return svcSignalEvent(this->handles[SYSTEMEVENT_INDEX_SGNLHANDLE]);
} }
}; };

View file

@ -10,10 +10,10 @@ enum DebugMonitorServiceCmd {
Dmnt_Cmd_GetNsoInfo = 2 Dmnt_Cmd_GetNsoInfo = 2
}; };
class DebugMonitorService : IServiceObject { class DebugMonitorService final : IServiceObject {
public: public:
virtual Result dispatch(IpcParsedCommand &r, IpcCommand &out_c, u64 cmd_id, u8 *pointer_buffer, size_t pointer_buffer_size); Result dispatch(IpcParsedCommand &r, IpcCommand &out_c, u64 cmd_id, u8 *pointer_buffer, size_t pointer_buffer_size) override;
virtual Result handle_deferred() { Result handle_deferred() override {
/* This service will never defer. */ /* This service will never defer. */
return 0; return 0;
} }
@ -23,4 +23,4 @@ class DebugMonitorService : IServiceObject {
std::tuple<Result> add_title_to_launch_queue(u64 tid, InPointer<char> args); std::tuple<Result> add_title_to_launch_queue(u64 tid, InPointer<char> args);
std::tuple<Result> clear_launch_queue(u64 dat); std::tuple<Result> clear_launch_queue(u64 dat);
std::tuple<Result, u32> get_nso_info(u64 pid, OutPointerWithClientSize<Registration::NsoInfo> out); std::tuple<Result, u32> get_nso_info(u64 pid, OutPointerWithClientSize<Registration::NsoInfo> out);
}; };

View file

@ -12,7 +12,7 @@ enum ProcessManagerServiceCmd {
Pm_Cmd_UnregisterTitle = 3 Pm_Cmd_UnregisterTitle = 3
}; };
class ProcessManagerService : IServiceObject { class ProcessManagerService final : IServiceObject {
struct ProgramInfo { struct ProgramInfo {
u8 main_thread_priority; u8 main_thread_priority;
u8 default_cpu_id; u8 default_cpu_id;
@ -29,8 +29,8 @@ class ProcessManagerService : IServiceObject {
static_assert(sizeof(ProcessManagerService::ProgramInfo) == 0x400, "Incorrect ProgramInfo definition."); static_assert(sizeof(ProcessManagerService::ProgramInfo) == 0x400, "Incorrect ProgramInfo definition.");
public: public:
virtual Result dispatch(IpcParsedCommand &r, IpcCommand &out_c, u64 cmd_id, u8 *pointer_buffer, size_t pointer_buffer_size); Result dispatch(IpcParsedCommand &r, IpcCommand &out_c, u64 cmd_id, u8 *pointer_buffer, size_t pointer_buffer_size) override;
virtual Result handle_deferred() { Result handle_deferred() override {
/* This service will never defer. */ /* This service will never defer. */
return 0; return 0;
} }
@ -44,4 +44,4 @@ class ProcessManagerService : IServiceObject {
/* Utilities */ /* Utilities */
Result populate_program_info_buffer(ProcessManagerService::ProgramInfo *out, Registration::TidSid *tid_sid); Result populate_program_info_buffer(ProcessManagerService::ProgramInfo *out, Registration::TidSid *tid_sid);
}; };

View file

@ -12,7 +12,7 @@ enum RoServiceCmd {
Ro_Cmd_Initialize = 4, Ro_Cmd_Initialize = 4,
}; };
class RelocatableObjectsService : IServiceObject { class RelocatableObjectsService final : IServiceObject {
Handle process_handle; Handle process_handle;
u64 process_id; u64 process_id;
bool has_initialized; bool has_initialized;
@ -24,8 +24,8 @@ class RelocatableObjectsService : IServiceObject {
svcCloseHandle(this->process_handle); svcCloseHandle(this->process_handle);
} }
} }
virtual Result dispatch(IpcParsedCommand &r, IpcCommand &out_c, u64 cmd_id, u8 *pointer_buffer, size_t pointer_buffer_size); Result dispatch(IpcParsedCommand &r, IpcCommand &out_c, u64 cmd_id, u8 *pointer_buffer, size_t pointer_buffer_size) override;
virtual Result handle_deferred() { Result handle_deferred() override {
/* This service will never defer. */ /* This service will never defer. */
return 0; return 0;
} }
@ -37,4 +37,4 @@ class RelocatableObjectsService : IServiceObject {
std::tuple<Result> load_nrr(PidDescriptor pid_desc, u64 nrr_address, u64 nrr_size); std::tuple<Result> load_nrr(PidDescriptor pid_desc, u64 nrr_address, u64 nrr_size);
std::tuple<Result> unload_nrr(PidDescriptor pid_desc, u64 nrr_address); std::tuple<Result> unload_nrr(PidDescriptor pid_desc, u64 nrr_address);
std::tuple<Result> initialize(PidDescriptor pid_desc, CopiedHandle process_h); std::tuple<Result> initialize(PidDescriptor pid_desc, CopiedHandle process_h);
}; };

View file

@ -7,10 +7,10 @@ enum ShellServiceCmd {
Shell_Cmd_ClearLaunchQueue = 1 Shell_Cmd_ClearLaunchQueue = 1
}; };
class ShellService : IServiceObject { class ShellService final : IServiceObject {
public: public:
virtual Result dispatch(IpcParsedCommand &r, IpcCommand &out_c, u64 cmd_id, u8 *pointer_buffer, size_t pointer_buffer_size); Result dispatch(IpcParsedCommand &r, IpcCommand &out_c, u64 cmd_id, u8 *pointer_buffer, size_t pointer_buffer_size) override;
virtual Result handle_deferred() { Result handle_deferred() override {
/* This service will never defer. */ /* This service will never defer. */
return 0; return 0;
} }
@ -19,4 +19,4 @@ class ShellService : IServiceObject {
/* Actual commands. */ /* Actual commands. */
std::tuple<Result> add_title_to_launch_queue(u64 tid, InPointer<char> args); std::tuple<Result> add_title_to_launch_queue(u64 tid, InPointer<char> args);
std::tuple<Result> clear_launch_queue(u64 dat); std::tuple<Result> clear_launch_queue(u64 dat);
}; };

View file

@ -7,13 +7,13 @@ enum BootModeCmd {
BootMode_Cmd_SetMaintenanceBoot = 1 BootMode_Cmd_SetMaintenanceBoot = 1
}; };
class BootModeService : IServiceObject { class BootModeService final : IServiceObject, public IpcCommandWrapper<BootModeService> {
public: public:
virtual Result dispatch(IpcParsedCommand &r, IpcCommand &out_c, u64 cmd_id, u8 *pointer_buffer, size_t pointer_buffer_size); Result dispatch(IpcParsedCommand &r, IpcCommand &out_c, u64 cmd_id, u8 *pointer_buffer, size_t pointer_buffer_size) override;
virtual Result handle_deferred(); Result handle_deferred() override;
private: private:
/* Actual commands. */ /* Actual commands. */
std::tuple<Result, bool> get_boot_mode(); std::tuple<Result, bool> get_boot_mode();
std::tuple<Result> set_maintenance_boot(); std::tuple<Result> set_maintenance_boot();
}; };

View file

@ -23,10 +23,10 @@ enum DmntCmd_5X {
Dmnt_Cmd_5X_EnableDebugForApplication = 5, Dmnt_Cmd_5X_EnableDebugForApplication = 5,
}; };
class DebugMonitorService : IServiceObject { class DebugMonitorService final : IServiceObject {
public: public:
virtual Result dispatch(IpcParsedCommand &r, IpcCommand &out_c, u64 cmd_id, u8 *pointer_buffer, size_t pointer_buffer_size); Result dispatch(IpcParsedCommand &r, IpcCommand &out_c, u64 cmd_id, u8 *pointer_buffer, size_t pointer_buffer_size) override;
virtual Result handle_deferred(); Result handle_deferred() override;
private: private:
/* Actual commands. */ /* Actual commands. */
@ -37,4 +37,4 @@ class DebugMonitorService : IServiceObject {
std::tuple<Result, CopiedHandle> enable_debug_for_tid(u64 tid); std::tuple<Result, CopiedHandle> enable_debug_for_tid(u64 tid);
std::tuple<Result, u64> get_application_process_id(); std::tuple<Result, u64> get_application_process_id();
std::tuple<Result, CopiedHandle> enable_debug_for_application(); std::tuple<Result, CopiedHandle> enable_debug_for_application();
}; };

View file

@ -6,12 +6,12 @@ enum InformationCmd {
Information_Cmd_GetTitleId = 0, Information_Cmd_GetTitleId = 0,
}; };
class InformationService : IServiceObject { class InformationService final : IServiceObject {
public: public:
virtual Result dispatch(IpcParsedCommand &r, IpcCommand &out_c, u64 cmd_id, u8 *pointer_buffer, size_t pointer_buffer_size); Result dispatch(IpcParsedCommand &r, IpcCommand &out_c, u64 cmd_id, u8 *pointer_buffer, size_t pointer_buffer_size) override;
virtual Result handle_deferred(); Result handle_deferred() override;
private: private:
/* Actual commands. */ /* Actual commands. */
std::tuple<Result, u64> get_title_id(u64 pid); std::tuple<Result, u64> get_title_id(u64 pid);
}; };

View file

@ -2,7 +2,7 @@
#include <switch.h> #include <switch.h>
#include <stratosphere.hpp> #include <stratosphere.hpp>
class ProcessWaiter : public IWaitable { class ProcessWaiter final : public IWaitable {
public: public:
Registration::Process process; Registration::Process process;
@ -19,33 +19,33 @@ class ProcessWaiter : public IWaitable {
} }
/* IWaitable */ /* IWaitable */
virtual unsigned int get_num_waitables() { unsigned int get_num_waitables() override {
return 1; return 1;
} }
virtual void get_waitables(IWaitable **dst) { void get_waitables(IWaitable **dst) override {
dst[0] = this; dst[0] = this;
} }
virtual void delete_child(IWaitable *child) { void delete_child(IWaitable *child) override {
/* TODO: Panic, because we can never have any children. */ /* TODO: Panic, because we can never have any children. */
} }
virtual Handle get_handle() { Handle get_handle() override {
return this->process.handle; return this->process.handle;
} }
virtual void handle_deferred() { void handle_deferred() override {
/* TODO: Panic, because we can never be deferred. */ /* TODO: Panic, because we can never be deferred. */
} }
virtual Result handle_signaled(u64 timeout) { Result handle_signaled(u64 timeout) override {
Registration::HandleSignaledProcess(this->get_process()); Registration::HandleSignaledProcess(this->get_process());
return 0; return 0;
} }
}; };
class ProcessList : public IWaitable { class ProcessList final : public IWaitable {
private: private:
HosRecursiveMutex mutex; HosRecursiveMutex mutex;
public: public:
@ -64,11 +64,11 @@ class ProcessList : public IWaitable {
} }
/* IWaitable */ /* IWaitable */
virtual unsigned int get_num_waitables() { unsigned int get_num_waitables() override {
return process_waiters.size(); return process_waiters.size();
} }
virtual void get_waitables(IWaitable **dst) { void get_waitables(IWaitable **dst) override {
Lock(); Lock();
for (unsigned int i = 0; i < process_waiters.size(); i++) { for (unsigned int i = 0; i < process_waiters.size(); i++) {
dst[i] = process_waiters[i]; dst[i] = process_waiters[i];
@ -76,20 +76,20 @@ class ProcessList : public IWaitable {
Unlock(); Unlock();
} }
virtual void delete_child(IWaitable *child) { void delete_child(IWaitable *child) override {
/* TODO: Panic, because we should never be asked to delete a child. */ /* TODO: Panic, because we should never be asked to delete a child. */
} }
virtual Handle get_handle() { Handle get_handle() override {
/* TODO: Panic, because we don't have a handle. */ /* TODO: Panic, because we don't have a handle. */
return 0; return 0;
} }
virtual void handle_deferred() { void handle_deferred() override {
/* TODO: Panic, because we can never be deferred. */ /* TODO: Panic, because we can never be deferred. */
} }
virtual Result handle_signaled(u64 timeout) { Result handle_signaled(u64 timeout) override {
/* TODO: Panic, because we can never be signaled. */ /* TODO: Panic, because we can never be signaled. */
return 0; return 0;
} }

View file

@ -30,10 +30,10 @@ enum ShellCmd_5X {
Shell_Cmd_5X_BoostSystemMemoryResourceLimit = 7 Shell_Cmd_5X_BoostSystemMemoryResourceLimit = 7
}; };
class ShellService : IServiceObject { class ShellService final : IServiceObject {
public: public:
virtual Result dispatch(IpcParsedCommand &r, IpcCommand &out_c, u64 cmd_id, u8 *pointer_buffer, size_t pointer_buffer_size); Result dispatch(IpcParsedCommand &r, IpcCommand &out_c, u64 cmd_id, u8 *pointer_buffer, size_t pointer_buffer_size) override;
virtual Result handle_deferred(); Result handle_deferred() override;
private: private:
/* Actual commands. */ /* Actual commands. */
@ -47,4 +47,4 @@ class ShellService : IServiceObject {
std::tuple<Result> notify_boot_finished(); std::tuple<Result> notify_boot_finished();
std::tuple<Result, u64> get_application_process_id(); std::tuple<Result, u64> get_application_process_id();
std::tuple<Result> boost_system_memory_resource_limit(u64 sysmem_size); std::tuple<Result> boost_system_memory_resource_limit(u64 sysmem_size);
}; };

View file

@ -7,13 +7,13 @@ enum ManagerServiceCmd {
Manager_Cmd_UnregisterProcess = 1 Manager_Cmd_UnregisterProcess = 1
}; };
class ManagerService : IServiceObject { class ManagerService final : IServiceObject {
public: public:
virtual Result dispatch(IpcParsedCommand &r, IpcCommand &out_c, u64 cmd_id, u8 *pointer_buffer, size_t pointer_buffer_size); Result dispatch(IpcParsedCommand &r, IpcCommand &out_c, u64 cmd_id, u8 *pointer_buffer, size_t pointer_buffer_size) override;
virtual Result handle_deferred(); Result handle_deferred() override;
private: private:
/* Actual commands. */ /* Actual commands. */
std::tuple<Result> register_process(u64 pid, InBuffer<u8> acid_sac, InBuffer<u8> aci0_sac); std::tuple<Result> register_process(u64 pid, InBuffer<u8> acid_sac, InBuffer<u8> aci0_sac);
std::tuple<Result> unregister_process(u64 pid); std::tuple<Result> unregister_process(u64 pid);
}; };

View file

@ -12,15 +12,15 @@ enum UserServiceCmd {
User_Cmd_AtmosphereUninstallMitm = 65001 User_Cmd_AtmosphereUninstallMitm = 65001
}; };
class UserService : IServiceObject { class UserService final : IServiceObject {
u64 pid; u64 pid;
bool has_initialized; bool has_initialized;
u64 deferred_service; u64 deferred_service;
public: public:
UserService() : pid(U64_MAX), has_initialized(false), deferred_service(0) { } UserService() : pid(U64_MAX), has_initialized(false), deferred_service(0) { }
virtual Result dispatch(IpcParsedCommand &r, IpcCommand &out_c, u64 cmd_id, u8 *pointer_buffer, size_t pointer_buffer_size); Result dispatch(IpcParsedCommand &r, IpcCommand &out_c, u64 cmd_id, u8 *pointer_buffer, size_t pointer_buffer_size) override;
virtual Result handle_deferred(); Result handle_deferred() override;
private: private:
/* Actual commands. */ /* Actual commands. */
@ -33,4 +33,4 @@ class UserService : IServiceObject {
/* Atmosphere commands. */ /* Atmosphere commands. */
std::tuple<Result, MovedHandle> install_mitm(u64 service); std::tuple<Result, MovedHandle> install_mitm(u64 service);
std::tuple<Result> uninstall_mitm(u64 service); std::tuple<Result> uninstall_mitm(u64 service);
}; };