diff options
Diffstat (limited to 'src/core/module/ModuleManager.cpp')
-rw-r--r-- | src/core/module/ModuleManager.cpp | 53 |
1 files changed, 28 insertions, 25 deletions
diff --git a/src/core/module/ModuleManager.cpp b/src/core/module/ModuleManager.cpp index 4dcc9595..1c778197 100644 --- a/src/core/module/ModuleManager.cpp +++ b/src/core/module/ModuleManager.cpp @@ -29,6 +29,7 @@ #include "ModuleManager.h" #include <boost/format.hpp> +#include <utility> #include "core/module/GlobalModuleContext.h" #include "core/module/GlobalRegisterTable.h" @@ -49,7 +50,7 @@ class ModuleManager::Impl { task_runner_->Start(); } - void RegisterModule(ModulePtr module) { + void RegisterModule(const ModulePtr& module) { task_runner_->PostTask(new Thread::Task( [=](GpgFrontend::DataObjectPtr) -> int { module->SetGPC(gmc_); @@ -59,55 +60,56 @@ class ModuleManager::Impl { __func__, nullptr)); } - void TriggerEvent(EventRefrernce event) { + void TriggerEvent(const EventRefrernce& event) { task_runner_->PostTask(new Thread::Task( - [=](GpgFrontend::DataObjectPtr) -> int { + [=](const GpgFrontend::DataObjectPtr&) -> int { gmc_->TriggerEvent(event); return 0; }, __func__, nullptr)); } - void ActiveModule(ModuleIdentifier identifier) { + void ActiveModule(const ModuleIdentifier& identifier) { task_runner_->PostTask(new Thread::Task( - [=](GpgFrontend::DataObjectPtr) -> int { + [=](const GpgFrontend::DataObjectPtr&) -> int { gmc_->ActiveModule(identifier); return 0; }, __func__, nullptr)); } - std::optional<TaskRunnerPtr> GetTaskRunner(ModuleIdentifier module_id) { - return gmc_->GetTaskRunner(module_id); + auto GetTaskRunner(ModuleIdentifier module_id) + -> std::optional<TaskRunnerPtr> { + return gmc_->GetTaskRunner(std::move(module_id)); } - bool UpsertRTValue(Namespace n, Key k, std::any v) { + auto UpsertRTValue(Namespace n, Key k, std::any v) -> bool { return grt_->PublishKV(n, k, v); } - std::optional<std::any> RetrieveRTValue(Namespace n, Key k) { + auto RetrieveRTValue(Namespace n, Key k) -> std::optional<std::any> { return grt_->LookupKV(n, k); } - bool ListenPublish(QObject* o, Namespace n, Key k, LPCallback c) { + auto ListenPublish(QObject* o, Namespace n, Key k, LPCallback c) -> bool { return grt_->ListenPublish(o, n, k, c); } private: - static ModuleMangerPtr global_module_manager_; + static ModuleMangerPtr global_module_manager; TaskRunnerPtr task_runner_; GMCPtr gmc_; GRTPtr grt_; }; -bool UpsertRTValue(const std::string& namespace_, const std::string& key, - const std::any& value) { +auto UpsertRTValue(const std::string& namespace_, const std::string& key, + const std::any& value) -> bool { return ModuleManager::GetInstance()->UpsertRTValue(namespace_, key, std::any(value)); } -bool GPGFRONTEND_CORE_EXPORT ListenRTPublishEvent(QObject* o, Namespace n, - Key k, LPCallback c) { +auto GPGFRONTEND_CORE_EXPORT ListenRTPublishEvent(QObject* o, Namespace n, + Key k, LPCallback c) -> bool { return ModuleManager::GetInstance()->ListenRTPublish(o, n, k, c); } @@ -115,7 +117,7 @@ ModuleManager::ModuleManager() : p_(std::make_unique<Impl>()) {} ModuleManager::~ModuleManager() = default; -ModuleMangerPtr ModuleManager::GetInstance() { +auto ModuleManager::GetInstance() -> ModuleMangerPtr { if (g_ == nullptr) g_ = std::shared_ptr<ModuleManager>(new ModuleManager()); return g_; } @@ -132,28 +134,29 @@ void ModuleManager::ActiveModule(ModuleIdentifier identifier) { return p_->ActiveModule(identifier); } -std::optional<TaskRunnerPtr> ModuleManager::GetTaskRunner( - ModuleIdentifier module_id) { - return p_->GetTaskRunner(module_id); +auto ModuleManager::GetTaskRunner(ModuleIdentifier module_id) + -> std::optional<TaskRunnerPtr> { + return p_->GetTaskRunner(std::move(module_id)); } -bool ModuleManager::UpsertRTValue(Namespace n, Key k, std::any v) { +auto ModuleManager::UpsertRTValue(Namespace n, Key k, std::any v) -> bool { return p_->UpsertRTValue(n, k, v); } -std::optional<std::any> ModuleManager::RetrieveRTValue(Namespace n, Key k) { +auto ModuleManager::RetrieveRTValue(Namespace n, Key k) + -> std::optional<std::any> { return p_->RetrieveRTValue(n, k); } -bool ModuleManager::ListenRTPublish(QObject* o, Namespace n, Key k, - LPCallback c) { +auto ModuleManager::ListenRTPublish(QObject* o, Namespace n, Key k, + LPCallback c) -> bool { return p_->ListenPublish(o, n, k, c); } -ModuleIdentifier GetRealModuleIdentifier(const ModuleIdentifier& id) { +auto GetRealModuleIdentifier(const ModuleIdentifier& m_id) -> ModuleIdentifier { // WARNING: when YOU need to CHANGE this line, YOU SHOULD change the same code // in Module.cpp as well. - return (boost::format("__module_%1%") % id).str(); + return (boost::format("__module_%1%") % m_id).str(); } } // namespace GpgFrontend::Module
\ No newline at end of file |