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 GetChannel(ModuleRawPtr) -> int;
62 
63  static auto GetDefaultChannel(ModuleRawPtr) -> int;
64 
65  auto GetTaskRunner(ModuleRawPtr) -> std::optional<TaskRunnerPtr>;
66 
67  auto GetTaskRunner(ModuleIdentifier) -> std::optional<TaskRunnerPtr>;
68 
69  auto GetGlobalTaskRunner() -> std::optional<TaskRunnerPtr>;
70 
71  auto RegisterModule(ModulePtr) -> bool;
72 
73  auto ActiveModule(ModuleIdentifier) -> bool;
74 
75  auto DeactivateModule(ModuleIdentifier) -> bool;
76 
77  auto ListenEvent(ModuleIdentifier, EventIdentifier) -> bool;
78 
79  auto TriggerEvent(EventRefrernce) -> bool;
80 
81  auto IsModuleActivated(ModuleIdentifier) -> bool;
82 
83  private:
84  class Impl;
85  SecureUniquePtr<Impl> p_;
86 };
87 
88 } // namespace GpgFrontend::Module
Definition: GlobalModuleContext.cpp:44
Definition: GlobalModuleContext.h:54
Definition: Module.h:47
Definition: Event.cpp:31