diff options
author | saturneric <[email protected]> | 2023-10-17 15:45:10 +0000 |
---|---|---|
committer | saturneric <[email protected]> | 2023-10-17 15:45:10 +0000 |
commit | 459cd3d0e512a1166b3a09233c22b7357b514760 (patch) | |
tree | 9ab0484a6d17ca7971f54f46a9d74b1c971f8b28 /src/module/system/ModuleManager.h | |
parent | fix: slove compile issues (diff) | |
download | GpgFrontend-459cd3d0e512a1166b3a09233c22b7357b514760.tar.gz GpgFrontend-459cd3d0e512a1166b3a09233c22b7357b514760.zip |
refactor: move module system to core and make it work
Diffstat (limited to '')
-rw-r--r-- | src/core/module/ModuleManager.h (renamed from src/module/system/ModuleManager.h) | 23 |
1 files changed, 21 insertions, 2 deletions
diff --git a/src/module/system/ModuleManager.h b/src/core/module/ModuleManager.h index fc046d1a..bb201ebe 100644 --- a/src/module/system/ModuleManager.h +++ b/src/core/module/ModuleManager.h @@ -32,7 +32,6 @@ #include <memory> #include <string> -#include "GpgFrontendModuleSystemExport.h" #include "core/GpgFrontendCore.h" #include "core/thread/Task.h" @@ -55,7 +54,7 @@ using ModulePtr = std::shared_ptr<Module>; using ModuleMangerPtr = std::shared_ptr<ModuleManager>; using GlobalModuleContextPtr = std::shared_ptr<GlobalModuleContext>; -class GPGFRONTEND_MODULE_SYSTEM_EXPORT ModuleManager : public QObject { +class GPGFRONTEND_CORE_EXPORT ModuleManager : public QObject { Q_OBJECT public: ~ModuleManager(); @@ -80,6 +79,26 @@ class GPGFRONTEND_MODULE_SYSTEM_EXPORT ModuleManager : public QObject { ModuleManager(); }; +template <typename T, typename... Args> +void RegisterModule(Args&&... args) { + ModuleManager::GetInstance()->RegisterModule( + std::make_shared<T>(std::forward<Args>(args)...)); +} + +template <typename T, typename... Args> +void RegisterAndActivateModule(Args&&... args) { + auto manager = ModuleManager::GetInstance(); + auto module = std::make_shared<T>(std::forward<Args>(args)...); + manager->RegisterModule(module); + manager->ActiveModule(module->GetModuleIdentifier()); +} + +template <typename... Args> +void TriggerEvent(const std::string& eventIdentifier, Args&&... args) { + ModuleManager::GetInstance()->TriggerEvent(std::make_shared<Event>( + std::move(MakeEvent(eventIdentifier, std::forward<Args>(args)...)))); +} + } // namespace GpgFrontend::Module #endif // GPGFRONTEND_MODULEMANAGER_H
\ No newline at end of file |