aboutsummaryrefslogtreecommitdiffstats
path: root/src/core/module/ModuleManager.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/core/module/ModuleManager.h')
-rw-r--r--src/core/module/ModuleManager.h32
1 files changed, 32 insertions, 0 deletions
diff --git a/src/core/module/ModuleManager.h b/src/core/module/ModuleManager.h
index 66fa9db6..586627b6 100644
--- a/src/core/module/ModuleManager.h
+++ b/src/core/module/ModuleManager.h
@@ -50,6 +50,10 @@ using ModuleMangerPtr = std::shared_ptr<ModuleManager>;
using GMCPtr = std::shared_ptr<GlobalModuleContext>;
using Namespace = std::string;
using Key = std::string;
+using LPCallback = std::function<void(Namespace, Key, int)>;
+
+ModuleIdentifier GPGFRONTEND_CORE_EXPORT
+GetRealModuleIdentifier(const ModuleIdentifier& id);
class GPGFRONTEND_CORE_EXPORT ModuleManager : public QObject {
Q_OBJECT
@@ -72,6 +76,8 @@ class GPGFRONTEND_CORE_EXPORT ModuleManager : public QObject {
std::optional<std::any> RetrieveRTValue(Namespace, Key);
+ bool ListenPublish(QObject*, Namespace, Key, LPCallback);
+
private:
class Impl;
std::unique_ptr<Impl> p_;
@@ -100,4 +106,30 @@ void TriggerEvent(const EventIdentifier& event_id, Args&&... args) {
std::move(MakeEvent(event_id, std::forward<Args>(args)...)));
}
+bool GPGFRONTEND_CORE_EXPORT UpsertRTValueTyped(const std::string& namespace_,
+ const std::string& key,
+ const std::any& value);
+
+template <typename T>
+std::optional<T> RetrieveRTValueTyped(const std::string& namespace_,
+ const std::string& key) {
+ auto any_value =
+ ModuleManager::GetInstance()->RetrieveRTValue(namespace_, key);
+ if (any_value && any_value->type() == typeid(T)) {
+ return std::any_cast<T>(*any_value);
+ }
+ return std::nullopt;
+}
+
+template <typename T>
+T RetrieveRTValueTypedOrDefault(const std::string& namespace_,
+ const std::string& key, const T& defaultValue) {
+ auto any_value =
+ ModuleManager::GetInstance()->RetrieveRTValue(namespace_, key);
+ if (any_value && any_value->type() == typeid(T)) {
+ return std::any_cast<T>(*any_value);
+ }
+ return defaultValue;
+}
+
} // namespace GpgFrontend::Module \ No newline at end of file