diff options
author | WBoerenkamps <wrj.boerenkamps@student.avans.nl> | 2024-11-12 15:08:37 +0100 |
---|---|---|
committer | WBoerenkamps <wrj.boerenkamps@student.avans.nl> | 2024-11-12 15:08:37 +0100 |
commit | 80e4e1eb78898879eed11648808ca6b65eecb304 (patch) | |
tree | 78d5d51ce36c32b235a4c061b5f51772fabdd8ea /src/crepe/api/EventManager.cpp | |
parent | 48fb3f48831b1db187942592343eb4a2dc6662fc (diff) |
removed auto from code
Diffstat (limited to 'src/crepe/api/EventManager.cpp')
-rw-r--r-- | src/crepe/api/EventManager.cpp | 21 |
1 files changed, 16 insertions, 5 deletions
diff --git a/src/crepe/api/EventManager.cpp b/src/crepe/api/EventManager.cpp index 869ec74..3d8558b 100644 --- a/src/crepe/api/EventManager.cpp +++ b/src/crepe/api/EventManager.cpp @@ -7,6 +7,9 @@ void EventManager::dispatch_events() { auto& event = std::get<0>(*event_it); int channel = std::get<1>(*event_it); std::type_index event_type = std::get<2>(*event_it); + + bool event_handled = false; + if (channel) { auto handlers_it = subscribers_by_event_id.find(event_type); if (handlers_it != subscribers_by_event_id.end()) { @@ -15,25 +18,33 @@ void EventManager::dispatch_events() { if (handlers != handlers_map.end()) { auto& callbacks = handlers->second; for (auto& handler : callbacks) { - handler->exec(*event); + if (handler->exec(*event)) { + event_it = events_queue.erase(event_it); + event_handled = true; + break; + } } } } } else { + // Handle event for all channels auto handlers_it = subscribers.find(event_type); if (handlers_it != subscribers.end()) { auto& handlers = handlers_it->second; for (auto& handler : handlers) { - handler->exec(*event); + if (handler->exec(*event)) { + event_it = events_queue.erase(event_it); + event_handled = true; + break; + } } } } - if (event->handled) { - event_it = events_queue.erase(event_it); - } else { + if (!event_handled) { ++event_it; } } } + |