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;
52 using EventRefrernce = std::shared_ptr<Event>;
53 using ModuleIdentifier = QString;
54 using ModulePtr = std::shared_ptr<Module>;
55 using ModuleMangerPtr = std::shared_ptr<ModuleManager>;
56 using GMCPtr = std::shared_ptr<GlobalModuleContext>;
57 using Namespace = QString;
59 using LPCallback = std::function<void(Namespace, Key,
int, std::any)>;
68 void RegisterModule(ModulePtr);
70 auto IsModuleActivated(ModuleIdentifier) -> bool;
72 void TriggerEvent(EventRefrernce);
74 void ActiveModule(ModuleIdentifier);
76 void DeactiveModule(ModuleIdentifier);
78 auto GetTaskRunner(ModuleIdentifier) -> std::optional<TaskRunnerPtr>;
82 auto RetrieveRTValue(Namespace, Key) -> std::optional<std::any>;
84 auto ListenRTPublish(QObject*, Namespace, Key, LPCallback) -> bool;
86 auto ListRTChildKeys(
const QString&,
const QString&) -> std::vector<Key>;
90 SecureUniquePtr<Impl> p_;
93 template <
typename T,
typename... Args>
94 void RegisterModule(Args&&... args) {
96 GpgFrontend::SecureCreateSharedObject<T>(std::forward<Args>(args)...));
99 template <
typename T,
typename... Args>
100 void RegisterAndActivateModule(Args&&... args) {
103 GpgFrontend::SecureCreateSharedObject<T>(std::forward<Args>(args)...);
104 manager.RegisterModule(module);
105 manager.ActiveModule(module->GetModuleIdentifier());
108 template <
typename... Args>
109 void TriggerEvent(
const EventIdentifier& event_id, Args&&... args,
110 Event::EventCallback e_cb =
nullptr) {
112 std::move(MakeEvent(event_id, std::forward<Args>(args)..., e_cb)));
121 auto GPGFRONTEND_CORE_EXPORT
IsModuleAcivate(ModuleIdentifier) -> bool;
132 auto GPGFRONTEND_CORE_EXPORT
UpsertRTValue(
const QString& namespace_,
134 const std::any& value) -> bool;
152 auto GPGFRONTEND_CORE_EXPORT
ListRTChildKeys(
const QString& namespace_,
156 template <
typename T>
157 auto RetrieveRTValueTyped(
const QString& namespace_,
const QString& key)
158 -> std::optional<T> {
161 if (any_value && any_value->type() ==
typeid(T)) {
162 return std::any_cast<T>(*any_value);
167 template <
typename T>
168 auto RetrieveRTValueTypedOrDefault(
const QString& namespace_,
169 const QString& key,
const T& defaultValue)
173 if (any_value && any_value->type() ==
typeid(T)) {
174 return std::any_cast<T>(*any_value);
Definition: ModuleManager.cpp:45
Definition: ModuleManager.h:62
Definition: GpgFunctionObject.h:58
static auto GetInstance(int channel=GpgFrontend::kGpgFrontendDefaultChannel) -> ModuleManager &
Get the Instance object.
Definition: GpgFunctionObject.h:80
Definition: TaskRunner.h:37
auto UpsertRTValue(const QString &namespace_, const QString &key, const std::any &value) -> bool
Definition: ModuleManager.cpp:122
auto ListRTChildKeys(const QString &namespace_, const QString &key) -> std::vector< Key >
Definition: ModuleManager.cpp:133
auto IsModuleAcivate(ModuleIdentifier id) -> bool
Definition: ModuleManager.cpp:118
auto ListenRTPublishEvent(QObject *o, Namespace n, Key k, LPCallback c) -> bool
Definition: ModuleManager.cpp:128
Definition: ModuleManager.h:39