Refactored profile manager sharing

This commit is contained in:
David Marcec 2018-08-11 13:17:06 +10:00
parent b76ddb7647
commit 6aa8ee6943
10 changed files with 28 additions and 20 deletions

View File

@ -197,17 +197,18 @@ void Module::Interface::GetBaasAccountManagerForApplication(Kernel::HLERequestCo
LOG_DEBUG(Service_ACC, "called"); LOG_DEBUG(Service_ACC, "called");
} }
Module::Interface::Interface(std::shared_ptr<Module> module, const char* name) Module::Interface::Interface(std::shared_ptr<Module> module,
: ServiceFramework(name), module(std::move(module)) { std::shared_ptr<ProfileManager> profile_manager, const char* name)
profile_manager = std::make_unique<ProfileManager>(); : ServiceFramework(name), module(std::move(module)),
} profile_manager(std::make_shared<ProfileManager>(*profile_manager)) {}
void InstallInterfaces(SM::ServiceManager& service_manager) { void InstallInterfaces(SM::ServiceManager& service_manager) {
auto module = std::make_shared<Module>(); auto module = std::make_shared<Module>();
std::make_shared<ACC_AA>(module)->InstallAsService(service_manager); auto profile_manager = std::make_shared<ProfileManager>();
std::make_shared<ACC_SU>(module)->InstallAsService(service_manager); std::make_shared<ACC_AA>(module, profile_manager)->InstallAsService(service_manager);
std::make_shared<ACC_U0>(module)->InstallAsService(service_manager); std::make_shared<ACC_SU>(module, profile_manager)->InstallAsService(service_manager);
std::make_shared<ACC_U1>(module)->InstallAsService(service_manager); std::make_shared<ACC_U0>(module, profile_manager)->InstallAsService(service_manager);
std::make_shared<ACC_U1>(module, profile_manager)->InstallAsService(service_manager);
} }
} // namespace Service::Account } // namespace Service::Account

View File

@ -13,7 +13,8 @@ class Module final {
public: public:
class Interface : public ServiceFramework<Interface> { class Interface : public ServiceFramework<Interface> {
public: public:
explicit Interface(std::shared_ptr<Module> module, const char* name); explicit Interface(std::shared_ptr<Module> module,
std::shared_ptr<ProfileManager> profile_manager, const char* name);
void GetUserCount(Kernel::HLERequestContext& ctx); void GetUserCount(Kernel::HLERequestContext& ctx);
void GetUserExistence(Kernel::HLERequestContext& ctx); void GetUserExistence(Kernel::HLERequestContext& ctx);
@ -25,11 +26,9 @@ public:
void GetBaasAccountManagerForApplication(Kernel::HLERequestContext& ctx); void GetBaasAccountManagerForApplication(Kernel::HLERequestContext& ctx);
void IsUserRegistrationRequestPermitted(Kernel::HLERequestContext& ctx); void IsUserRegistrationRequestPermitted(Kernel::HLERequestContext& ctx);
private:
std::unique_ptr<ProfileManager> profile_manager{};
protected: protected:
std::shared_ptr<Module> module; std::shared_ptr<Module> module;
std::shared_ptr<ProfileManager> profile_manager;
}; };
}; };

View File

@ -6,7 +6,8 @@
namespace Service::Account { namespace Service::Account {
ACC_AA::ACC_AA(std::shared_ptr<Module> module) : Module::Interface(std::move(module), "acc:aa") { ACC_AA::ACC_AA(std::shared_ptr<Module> module, std::shared_ptr<ProfileManager> profile_manager)
: Module::Interface(std::move(module), std::move(profile_manager), "acc:aa") {
static const FunctionInfo functions[] = { static const FunctionInfo functions[] = {
{0, nullptr, "EnsureCacheAsync"}, {0, nullptr, "EnsureCacheAsync"},
{1, nullptr, "LoadCache"}, {1, nullptr, "LoadCache"},

View File

@ -10,7 +10,8 @@ namespace Service::Account {
class ACC_AA final : public Module::Interface { class ACC_AA final : public Module::Interface {
public: public:
explicit ACC_AA(std::shared_ptr<Module> module); explicit ACC_AA(std::shared_ptr<Module> module,
std::shared_ptr<ProfileManager> profile_manager);
}; };
} // namespace Service::Account } // namespace Service::Account

View File

@ -6,7 +6,8 @@
namespace Service::Account { namespace Service::Account {
ACC_SU::ACC_SU(std::shared_ptr<Module> module) : Module::Interface(std::move(module), "acc:su") { ACC_SU::ACC_SU(std::shared_ptr<Module> module, std::shared_ptr<ProfileManager> profile_manager)
: Module::Interface(std::move(module), std::move(profile_manager), "acc:su") {
static const FunctionInfo functions[] = { static const FunctionInfo functions[] = {
{0, &ACC_SU::GetUserCount, "GetUserCount"}, {0, &ACC_SU::GetUserCount, "GetUserCount"},
{1, &ACC_SU::GetUserExistence, "GetUserExistence"}, {1, &ACC_SU::GetUserExistence, "GetUserExistence"},

View File

@ -11,7 +11,8 @@ namespace Account {
class ACC_SU final : public Module::Interface { class ACC_SU final : public Module::Interface {
public: public:
explicit ACC_SU(std::shared_ptr<Module> module); explicit ACC_SU(std::shared_ptr<Module> module,
std::shared_ptr<ProfileManager> profile_manager);
}; };
} // namespace Account } // namespace Account

View File

@ -6,7 +6,8 @@
namespace Service::Account { namespace Service::Account {
ACC_U0::ACC_U0(std::shared_ptr<Module> module) : Module::Interface(std::move(module), "acc:u0") { ACC_U0::ACC_U0(std::shared_ptr<Module> module, std::shared_ptr<ProfileManager> profile_manager)
: Module::Interface(std::move(module), std::move(profile_manager), "acc:u0") {
static const FunctionInfo functions[] = { static const FunctionInfo functions[] = {
{0, &ACC_U0::GetUserCount, "GetUserCount"}, {0, &ACC_U0::GetUserCount, "GetUserCount"},
{1, &ACC_U0::GetUserExistence, "GetUserExistence"}, {1, &ACC_U0::GetUserExistence, "GetUserExistence"},

View File

@ -10,7 +10,8 @@ namespace Service::Account {
class ACC_U0 final : public Module::Interface { class ACC_U0 final : public Module::Interface {
public: public:
explicit ACC_U0(std::shared_ptr<Module> module); explicit ACC_U0(std::shared_ptr<Module> module,
std::shared_ptr<ProfileManager> profile_manager);
}; };
} // namespace Service::Account } // namespace Service::Account

View File

@ -6,7 +6,8 @@
namespace Service::Account { namespace Service::Account {
ACC_U1::ACC_U1(std::shared_ptr<Module> module) : Module::Interface(std::move(module), "acc:u1") { ACC_U1::ACC_U1(std::shared_ptr<Module> module, std::shared_ptr<ProfileManager> profile_manager)
: Module::Interface(std::move(module), std::move(profile_manager), "acc:u1") {
static const FunctionInfo functions[] = { static const FunctionInfo functions[] = {
{0, &ACC_U1::GetUserCount, "GetUserCount"}, {0, &ACC_U1::GetUserCount, "GetUserCount"},
{1, &ACC_U1::GetUserExistence, "GetUserExistence"}, {1, &ACC_U1::GetUserExistence, "GetUserExistence"},

View File

@ -10,7 +10,8 @@ namespace Service::Account {
class ACC_U1 final : public Module::Interface { class ACC_U1 final : public Module::Interface {
public: public:
explicit ACC_U1(std::shared_ptr<Module> module); explicit ACC_U1(std::shared_ptr<Module> module,
std::shared_ptr<ProfileManager> profile_manager);
}; };
} // namespace Service::Account } // namespace Service::Account