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/src/eventManager.cpp | 41 +++++++++++++---------------------------- 1 file changed, 13 insertions(+), 28 deletions(-) (limited to 'mwe/events/src/eventManager.cpp') diff --git a/mwe/events/src/eventManager.cpp b/mwe/events/src/eventManager.cpp index 34a093d..9e7d880 100644 --- a/mwe/events/src/eventManager.cpp +++ b/mwe/events/src/eventManager.cpp @@ -2,33 +2,27 @@ void EventManager::shutdown() { subscribers.clear(); } -void EventManager::subscribe(int eventType, - std::unique_ptr && handler, +void EventManager::subscribe(int eventType, std::unique_ptr && handler, int eventId) { if (eventId) { std::unordered_map< - int, std::unordered_map< - int, std::vector>>>:: + int, std::unordered_map>>>:: iterator subscribers = subscribersByEventId.find(eventType); if (subscribers != subscribersByEventId.end()) { - std::unordered_map< - int, std::vector>> & + std::unordered_map>> & handlersMap = subscribers->second; std::unordered_map< - int, - std::vector>>::iterator - handlers + int, std::vector>>::iterator handlers = handlersMap.find(eventId); if (handlers != handlersMap.end()) { handlers->second.emplace_back(std::move(handler)); return; } } - subscribersByEventId[eventType][eventId].emplace_back( - std::move(handler)); + subscribersByEventId[eventType][eventId].emplace_back(std::move(handler)); } else { auto & handlers = subscribers[eventType]; @@ -36,29 +30,23 @@ void EventManager::subscribe(int eventType, } } -void EventManager::unsubscribe(int eventType, const std::string & handlerName, - int eventId) { +void EventManager::unsubscribe(int eventType, const std::string & handlerName, int eventId) { if (eventId) { std::unordered_map< - int, std::unordered_map< - int, std::vector>>>:: + int, std::unordered_map>>>:: iterator subscriberList = subscribersByEventId.find(eventType); if (subscriberList != subscribersByEventId.end()) { - std::unordered_map< - int, std::vector>> & + std::unordered_map>> & handlersMap = subscriberList->second; std::unordered_map< - int, - std::vector>>::iterator - handlers + int, std::vector>>::iterator handlers = handlersMap.find(eventId); if (handlers != handlersMap.end()) { std::vector> & callbacks = handlers->second; - for (std::vector< - std::unique_ptr>::iterator it + for (std::vector>::iterator it = callbacks.begin(); it != callbacks.end(); ++it) { if (it->get()->getType() == handlerName) { @@ -69,13 +57,11 @@ void EventManager::unsubscribe(int eventType, const std::string & handlerName, } } } else { - std::unordered_map< - int, std::vector>>::iterator + std::unordered_map>>::iterator handlersIt = subscribers.find(eventType); if (handlersIt != subscribers.end()) { - std::vector> & handlers - = handlersIt->second; + std::vector> & handlers = handlersIt->second; for (std::vector>::iterator it = handlers.begin(); it != handlers.end(); ++it) { @@ -90,8 +76,7 @@ void EventManager::unsubscribe(int eventType, const std::string & handlerName, void EventManager::triggerEvent(const Event & event_, int eventId) { if (eventId > 0) { - auto handlersIt - = subscribersByEventId[event_.getEventType()].find(eventId); + auto handlersIt = subscribersByEventId[event_.getEventType()].find(eventId); if (handlersIt != subscribersByEventId[event_.getEventType()].end()) { std::vector> & callbacks = handlersIt->second; -- cgit v1.2.3