From f51ddfac7b8948a43a40894185238c8a1ceeb5c4 Mon Sep 17 00:00:00 2001 From: Loek Le Blansch Date: Fri, 15 Nov 2024 17:25:12 +0100 Subject: wrap lines at column 95 instead of 80 --- mwe/events/include/customTypes.h | 11 +++-------- mwe/events/include/event.h | 10 +++------- mwe/events/include/eventManager.h | 30 ++++++++++++------------------ 3 files changed, 18 insertions(+), 33 deletions(-) (limited to 'mwe/events/include') diff --git a/mwe/events/include/customTypes.h b/mwe/events/include/customTypes.h index 415b989..5a7851b 100644 --- a/mwe/events/include/customTypes.h +++ b/mwe/events/include/customTypes.h @@ -5,14 +5,10 @@ struct Vector2 { float y; // Y component of the vector // Vector subtraction - Vector2 operator-(const Vector2 & other) const { - return {x - other.x, y - other.y}; - } + Vector2 operator-(const Vector2 & other) const { return {x - other.x, y - other.y}; } // Vector addition - Vector2 operator+(const Vector2 & other) const { - return {x + other.x, y + other.y}; - } + Vector2 operator+(const Vector2 & other) const { return {x + other.x, y + other.y}; } // Scalar multiplication Vector2 operator*(float scalar) const { return {x * scalar, y * scalar}; } @@ -31,8 +27,7 @@ struct Collision { Vector2 contactNormal; // Normal vector at the contact point // Constructor to initialize a Collision - Collision(int idA, int idB, const Vector2 & point, const Vector2 & normal, - float depth) + Collision(int idA, int idB, const Vector2 & point, const Vector2 & normal, float depth) : objectIdA(idA), objectIdB(idB), contactPoint(point), diff --git a/mwe/events/include/event.h b/mwe/events/include/event.h index 16c75bf..ee1bf52 100644 --- a/mwe/events/include/event.h +++ b/mwe/events/include/event.h @@ -20,9 +20,7 @@ public: \ static std::uint32_t typeID = UUIDGenerator::getUniqueID(); \ return typeID; \ } \ - virtual std::uint32_t getEventType() const override { \ - return getStaticEventType(); \ - } + virtual std::uint32_t getEventType() const override { return getStaticEventType(); } class Event { public: Event(std::string eventType); @@ -32,16 +30,14 @@ public: void addArgument(const std::string & key, const std::variant & value); - std::variant - getArgument(const std::string & key) const; + std::variant getArgument(const std::string & key) const; std::string getType() const; bool getHandled() const; void markHandled(); private: - std::unordered_map> - eventData; + std::unordered_map> eventData; bool isHandled = false; }; diff --git a/mwe/events/include/eventManager.h b/mwe/events/include/eventManager.h index 508a5e2..30e927f 100644 --- a/mwe/events/include/eventManager.h +++ b/mwe/events/include/eventManager.h @@ -18,11 +18,9 @@ public: } void shutdown(); - void subscribe(int eventType, - std::unique_ptr && handler, + void subscribe(int eventType, std::unique_ptr && handler, int eventId); - void unsubscribe(int eventType, const std::string & handlerName, - 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_, int eventId); void dispatchEvents(); @@ -30,11 +28,9 @@ public: private: EventManager() = default; std::vector, int>> eventsQueue; - std::unordered_map>> - subscribers; + std::unordered_map>> subscribers; std::unordered_map< - int, std::unordered_map< - int, std::vector>>> + int, std::unordered_map>>> subscribersByEventId; }; @@ -42,18 +38,16 @@ template inline void subscribe(const EventHandler & callback, int eventId = 0, const bool unsubscribeOnSuccess = false) { std::unique_ptr handler - = std::make_unique>( - callback, unsubscribeOnSuccess); - EventManager::getInstance().subscribe(EventType::getStaticEventType(), - std::move(handler), eventId); + = std::make_unique>(callback, unsubscribeOnSuccess); + EventManager::getInstance().subscribe(EventType::getStaticEventType(), std::move(handler), + eventId); } template -inline void unsubscribe(const EventHandler & callback, - int eventId = 0) { +inline void unsubscribe(const EventHandler & 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) { @@ -61,6 +55,6 @@ inline void triggerEvent(const Event & triggeredEvent, int eventId = 0) { } inline void queueEvent(std::unique_ptr && queuedEvent, int eventId = 0) { - EventManager::getInstance().queueEvent( - std::forward>(queuedEvent), eventId); + EventManager::getInstance().queueEvent(std::forward>(queuedEvent), + eventId); } -- cgit v1.2.3