34 #include "core/function/SecureMemoryAllocator.h"
35 #include "core/function/basic/GpgFunctionObject.h"
36 #include "core/module/Event.h"
37 #include "core/utils/MemoryUtils.h"
45 using TaskRunnerPtr = std::shared_ptr<Thread::TaskRunner>;
49 class GlobalModuleContext;
51 class GlobalRegisterTable;
53 using EventRefrernce = std::shared_ptr<Event>;
54 using ModuleIdentifier = QString;
55 using ModulePtr = std::shared_ptr<Module>;
56 using ModuleMangerPtr = std::shared_ptr<ModuleManager>;
57 using GMCPtr = std::shared_ptr<GlobalModuleContext>;
58 using Namespace = QString;
60 using LPCallback = std::function<void(Namespace, Key,
int, std::any)>;
69 auto LoadModule(QString,
bool) -> void;
71 auto SearchModule(ModuleIdentifier) -> ModulePtr;
73 auto ListAllRegisteredModuleID() -> QList<ModuleIdentifier>;
75 void RegisterModule(ModulePtr);
77 auto IsModuleActivated(ModuleIdentifier) -> bool;
79 auto IsIntegratedModule(ModuleIdentifier) -> bool;
81 void ListenEvent(ModuleIdentifier, EventIdentifier);
83 void TriggerEvent(EventRefrernce);
85 auto SearchEvent(EventTriggerIdentifier) -> std::optional<EventRefrernce>;
87 auto GetModuleListening(ModuleIdentifier) -> QList<EventIdentifier>;
89 void ActiveModule(ModuleIdentifier);
91 void DeactiveModule(ModuleIdentifier);
93 auto GetTaskRunner(ModuleIdentifier) -> std::optional<TaskRunnerPtr>;
97 auto RetrieveRTValue(Namespace, Key) -> std::optional<std::any>;
99 auto ListenRTPublish(QObject*, Namespace, Key, LPCallback) -> bool;
101 auto ListRTChildKeys(
const QString&,
const QString&) -> std::vector<Key>;
107 SecureUniquePtr<Impl> p_;
110 template <
typename T,
typename... Args>
111 void RegisterModule(Args&&... args) {
113 GpgFrontend::SecureCreateSharedObject<T>(std::forward<Args>(args)...));
116 template <
typename T,
typename... Args>
117 void RegisterAndActivateModule(Args&&... args) {
120 GpgFrontend::SecureCreateSharedObject<T>(std::forward<Args>(args)...);
121 manager.RegisterModule(module);
122 manager.ActiveModule(module->GetModuleIdentifier());
125 template <
typename... Args>
126 void TriggerEvent(
const EventIdentifier& event_id, Args&&... args,
127 Event::EventCallback e_cb =
nullptr) {
129 std::move(MakeEvent(event_id, std::forward<Args>(args)..., e_cb)));
149 auto GPGFRONTEND_CORE_EXPORT
UpsertRTValue(
const QString& namespace_,
151 const std::any& value) -> bool;
169 auto GPGFRONTEND_CORE_EXPORT
ListRTChildKeys(
const QString& namespace_,
173 template <
typename T>
174 auto RetrieveRTValueTyped(
const QString& namespace_,
const QString& key)
175 -> std::optional<T> {
178 if (any_value && any_value->type() ==
typeid(T)) {
179 return std::any_cast<T>(*any_value);
184 template <
typename T>
185 auto RetrieveRTValueTypedOrDefault(
const QString& namespace_,
186 const QString& key,
const T& defaultValue)
190 if (any_value && any_value->type() ==
typeid(T)) {
191 return std::any_cast<T>(*any_value);
Definition: GlobalRegisterTable.h:43
Definition: ModuleManager.cpp:48
Definition: ModuleManager.h:63
Definition: GpgFunctionObject.h:57
static auto GetInstance(int channel=GpgFrontend::kGpgFrontendDefaultChannel) -> ModuleManager &
Get the Instance object.
Definition: GpgFunctionObject.h:79
Definition: TaskRunner.h:37
auto UpsertRTValue(const QString &namespace_, const QString &key, const std::any &value) -> bool
Definition: ModuleManager.cpp:235
auto ListRTChildKeys(const QString &namespace_, const QString &key) -> std::vector< Key >
Definition: ModuleManager.cpp:246
auto IsModuleActivate(ModuleIdentifier id) -> bool
Definition: ModuleManager.cpp:231
auto ListenRTPublishEvent(QObject *o, Namespace n, Key k, LPCallback c) -> bool
Definition: ModuleManager.cpp:241
Definition: ModuleManager.h:39