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) -> void;
71 auto SearchModule(ModuleIdentifier) -> ModulePtr;
73 auto ListAllRegisteredModuleID() -> QList<ModuleIdentifier>;
75 void RegisterModule(ModulePtr);
77 auto IsModuleActivated(ModuleIdentifier) -> bool;
79 void ListenEvent(ModuleIdentifier, EventIdentifier);
81 void TriggerEvent(EventRefrernce);
83 auto SearchEvent(EventTriggerIdentifier) -> std::optional<EventRefrernce>;
85 auto GetModuleListening(ModuleIdentifier) -> QList<EventIdentifier>;
87 void ActiveModule(ModuleIdentifier);
89 void DeactiveModule(ModuleIdentifier);
91 auto GetTaskRunner(ModuleIdentifier) -> std::optional<TaskRunnerPtr>;
95 auto RetrieveRTValue(Namespace, Key) -> std::optional<std::any>;
97 auto ListenRTPublish(QObject*, Namespace, Key, LPCallback) -> bool;
99 auto ListRTChildKeys(
const QString&,
const QString&) -> std::vector<Key>;
105 SecureUniquePtr<Impl> p_;
108 template <
typename T,
typename... Args>
109 void RegisterModule(Args&&... args) {
111 GpgFrontend::SecureCreateSharedObject<T>(std::forward<Args>(args)...));
114 template <
typename T,
typename... Args>
115 void RegisterAndActivateModule(Args&&... args) {
118 GpgFrontend::SecureCreateSharedObject<T>(std::forward<Args>(args)...);
119 manager.RegisterModule(module);
120 manager.ActiveModule(module->GetModuleIdentifier());
123 template <
typename... Args>
124 void TriggerEvent(
const EventIdentifier& event_id, Args&&... args,
125 Event::EventCallback e_cb =
nullptr) {
127 std::move(MakeEvent(event_id, std::forward<Args>(args)..., e_cb)));
147 auto GPGFRONTEND_CORE_EXPORT
UpsertRTValue(
const QString& namespace_,
149 const std::any& value) -> bool;
167 auto GPGFRONTEND_CORE_EXPORT
ListRTChildKeys(
const QString& namespace_,
171 template <
typename T>
172 auto RetrieveRTValueTyped(
const QString& namespace_,
const QString& key)
173 -> std::optional<T> {
176 if (any_value && any_value->type() ==
typeid(T)) {
177 return std::any_cast<T>(*any_value);
182 template <
typename T>
183 auto RetrieveRTValueTypedOrDefault(
const QString& namespace_,
184 const QString& key,
const T& defaultValue)
188 if (any_value && any_value->type() ==
typeid(T)) {
189 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:212
auto ListRTChildKeys(const QString &namespace_, const QString &key) -> std::vector< Key >
Definition: ModuleManager.cpp:223
auto IsModuleActivate(ModuleIdentifier id) -> bool
Definition: ModuleManager.cpp:208
auto ListenRTPublishEvent(QObject *o, Namespace n, Key k, LPCallback c) -> bool
Definition: ModuleManager.cpp:218
Definition: ModuleManager.h:39