35 #include "core/GpgFrontendCore.h"
36 #include "core/model/DataObject.h"
42 using EventRefrernce = std::shared_ptr<Event>;
43 using EventIdentifier = QString;
44 using Evnets = std::vector<Event>;
46 class GPGFRONTEND_CORE_EXPORT
Event {
48 using ParameterValue = std::any;
49 using EventIdentifier = QString;
50 using ListenerIdentifier = QString;
52 std::function<void(EventIdentifier, ListenerIdentifier, DataObjectPtr)>;
58 explicit Event(
const QString&,
59 std::initializer_list<ParameterInitializer> = {},
60 EventCallback =
nullptr);
64 auto operator[](
const QString& key)
const -> std::optional<ParameterValue>;
66 auto operator==(
const Event& other)
const -> bool;
68 auto operator!=(
const Event& other)
const -> bool;
70 auto operator<(
const Event& other)
const -> bool;
72 auto operator<=(
const Event& other)
const -> bool;
74 explicit operator QString()
const;
76 auto GetIdentifier() -> EventIdentifier;
78 void AddParameter(
const QString& key,
const ParameterValue& value);
80 void ExecuteCallback(ListenerIdentifier, DataObjectPtr);
84 SecureUniquePtr<Impl> p_;
87 template <
typename... Args>
88 auto MakeEvent(
const EventIdentifier& event_id, Args&&... args,
89 Event::EventCallback e_cb) -> EventRefrernce {
90 std::initializer_list<Event::ParameterInitializer> params = {
91 Event::ParameterInitializer{std::forward<Args>(args)}...};
92 return GpgFrontend::SecureCreateSharedObject<Event>(event_id, params, e_cb);