GpgFrontend Project
A Free, Powerful, Easy-to-Use, Compact, Cross-Platform, and Installation-Free OpenPGP(pgp) Crypto Tool.
GlobalModuleContext.h
1 
29 #pragma once
30 
31 #include <optional>
32 
33 #include "core/module/Event.h"
34 #include "core/thread/TaskRunner.h"
35 #include "function/SecureMemoryAllocator.h"
36 #include "module/GlobalRegisterTable.h"
37 
38 namespace GpgFrontend::Module {
39 
40 class GlobalModuleContext;
41 class GlobalRegisterTable;
42 
43 class Module;
44 class ModuleManager;
45 using ModuleIdentifier = QString;
46 using ModulePtr = std::shared_ptr<Module>;
47 using ModuleRawPtr = Module*;
48 
49 using GMCPtr = std::shared_ptr<GlobalModuleContext>;
50 using GRTPtr = std::shared_ptr<GlobalRegisterTable>;
51 
52 using TaskRunnerPtr = std::shared_ptr<Thread::TaskRunner>;
53 
54 class GPGFRONTEND_CORE_EXPORT GlobalModuleContext : public QObject {
55  Q_OBJECT
56  public:
57  explicit GlobalModuleContext();
58 
59  ~GlobalModuleContext() override;
60 
61  auto SearchModule(ModuleIdentifier) -> ModulePtr;
62 
63  auto GetChannel(ModuleRawPtr) -> int;
64 
65  static auto GetDefaultChannel(ModuleRawPtr) -> int;
66 
67  auto GetTaskRunner(ModuleRawPtr) -> std::optional<TaskRunnerPtr>;
68 
69  auto GetTaskRunner(ModuleIdentifier) -> std::optional<TaskRunnerPtr>;
70 
71  auto GetGlobalTaskRunner() -> std::optional<TaskRunnerPtr>;
72 
73  auto RegisterModule(ModulePtr, bool) -> bool;
74 
75  auto ActiveModule(ModuleIdentifier) -> bool;
76 
77  auto DeactivateModule(ModuleIdentifier) -> bool;
78 
79  auto ListenEvent(ModuleIdentifier, EventIdentifier) -> bool;
80 
81  auto TriggerEvent(EventReference) -> bool;
82 
83  auto SearchEvent(EventTriggerIdentifier) -> std::optional<EventReference>;
84 
85  auto GetModuleListening(ModuleIdentifier) -> QList<EventIdentifier>;
86 
87  auto IsModuleActivated(ModuleIdentifier) -> bool;
88 
89  auto IsIntegratedModule(ModuleIdentifier) -> bool;
90 
91  auto ListAllRegisteredModuleID() -> QList<ModuleIdentifier>;
92 
93  private:
94  class Impl;
95  SecureUniquePtr<Impl> p_;
96 };
97 
98 } // namespace GpgFrontend::Module
Definition: GlobalModuleContext.cpp:45
Definition: GlobalModuleContext.h:54
Definition: Module.h:47
Definition: Event.cpp:33