diff options
Diffstat (limited to 'mwe/events/include')
-rw-r--r-- | mwe/events/include/event.h | 4 | ||||
-rw-r--r-- | mwe/events/include/eventHandler.h | 7 | ||||
-rw-r--r-- | mwe/events/include/eventManager.h | 25 |
3 files changed, 21 insertions, 15 deletions
diff --git a/mwe/events/include/event.h b/mwe/events/include/event.h index ee1bf52..6df98ee 100644 --- a/mwe/events/include/event.h +++ b/mwe/events/include/event.h @@ -27,8 +27,8 @@ public: virtual ~Event() = default; virtual std::uint32_t getEventType() const = 0; virtual std::string toString() const; - void addArgument(const std::string & key, - const std::variant<int, std::string, float> & value); + void + addArgument(const std::string & key, const std::variant<int, std::string, float> & value); std::variant<int, std::string, float> getArgument(const std::string & key) const; diff --git a/mwe/events/include/eventHandler.h b/mwe/events/include/eventHandler.h index 3a83b15..8598cee 100644 --- a/mwe/events/include/eventHandler.h +++ b/mwe/events/include/eventHandler.h @@ -22,8 +22,9 @@ private: template <typename EventType> class EventHandlerWrapper : public IEventHandlerWrapper { public: - explicit EventHandlerWrapper(const EventHandler<EventType> & handler, - const bool destroyOnSuccess = false) + explicit EventHandlerWrapper( + const EventHandler<EventType> & handler, const bool destroyOnSuccess = false + ) : m_handler(handler), m_handlerType(m_handler.target_type().name()), m_destroyOnSuccess(destroyOnSuccess) { @@ -42,5 +43,5 @@ private: EventHandler<EventType> m_handler; const std::string m_handlerType; - bool m_destroyOnSuccess{false}; + bool m_destroyOnSuccess {false}; }; diff --git a/mwe/events/include/eventManager.h b/mwe/events/include/eventManager.h index 30e927f..43906e8 100644 --- a/mwe/events/include/eventManager.h +++ b/mwe/events/include/eventManager.h @@ -18,8 +18,8 @@ public: } void shutdown(); - void subscribe(int eventType, std::unique_ptr<IEventHandlerWrapper> && handler, - int eventId); + void + subscribe(int eventType, std::unique_ptr<IEventHandlerWrapper> && handler, int eventId); void unsubscribe(int eventType, const std::string & handlerName, int eventId); void triggerEvent(const Event & event_, int eventId); void queueEvent(std::unique_ptr<Event> && event_, int eventId); @@ -35,19 +35,23 @@ private: }; template <typename EventType> -inline void subscribe(const EventHandler<EventType> & callback, int eventId = 0, - const bool unsubscribeOnSuccess = false) { +inline void subscribe( + const EventHandler<EventType> & callback, int eventId = 0, + const bool unsubscribeOnSuccess = false +) { std::unique_ptr<IEventHandlerWrapper> handler = std::make_unique<EventHandlerWrapper<EventType>>(callback, unsubscribeOnSuccess); - EventManager::getInstance().subscribe(EventType::getStaticEventType(), std::move(handler), - eventId); + EventManager::getInstance().subscribe( + EventType::getStaticEventType(), std::move(handler), eventId + ); } template <typename EventType> inline void unsubscribe(const EventHandler<EventType> & callback, int eventId = 0) { const std::string handlerName = callback.target_type().name(); - EventManager::getInstance().unsubscribe(EventType::getStaticEventType(), handlerName, - eventId); + EventManager::getInstance().unsubscribe( + EventType::getStaticEventType(), handlerName, eventId + ); } inline void triggerEvent(const Event & triggeredEvent, int eventId = 0) { @@ -55,6 +59,7 @@ inline void triggerEvent(const Event & triggeredEvent, int eventId = 0) { } inline void queueEvent(std::unique_ptr<Event> && queuedEvent, int eventId = 0) { - EventManager::getInstance().queueEvent(std::forward<std::unique_ptr<Event>>(queuedEvent), - eventId); + EventManager::getInstance().queueEvent( + std::forward<std::unique_ptr<Event>>(queuedEvent), eventId + ); } |