aboutsummaryrefslogtreecommitdiff
path: root/src/crepe/api/EventManager.h
diff options
context:
space:
mode:
authorWBoerenkamps <wrj.boerenkamps@student.avans.nl>2024-11-13 12:33:16 +0100
committerWBoerenkamps <wrj.boerenkamps@student.avans.nl>2024-11-13 12:33:16 +0100
commite4b3162d28a635af37dd7ca1f71db16e0d196864 (patch)
tree800bf855db81bf78ad9acdc09e98559c20945956 /src/crepe/api/EventManager.h
parentf1ba2a5607f23ed0b23d74240ea66cb1f8d2c1ad (diff)
moved get_instance
Diffstat (limited to 'src/crepe/api/EventManager.h')
-rw-r--r--src/crepe/api/EventManager.h9
1 files changed, 3 insertions, 6 deletions
diff --git a/src/crepe/api/EventManager.h b/src/crepe/api/EventManager.h
index d3a14da..b963ce3 100644
--- a/src/crepe/api/EventManager.h
+++ b/src/crepe/api/EventManager.h
@@ -34,10 +34,7 @@ public:
*
* \return Reference to the EventManager instance.
*/
- static EventManager & get_instance() {
- static EventManager instance;
- return instance;
- }
+ static EventManager & get_instance();
/**
* \brief Subscribe to an event.
@@ -150,7 +147,7 @@ void EventManager::trigger_event(const EventType & event, int channel) {
std::type_index event_type = std::type_index(typeid(EventType));
if (channel > 0) {
- std::unordered_map<int, std::vector<std::unique_ptr<IEventHandlerWrapper>>>& handlers_map = subscribers_by_event_id[event_type];
+ std::unordered_map<int, std::vector<std::unique_ptr<IEventHandlerWrapper>>>& handlers_map = this->subscribers_by_event_id[event_type];
std::unordered_map<int, std::vector<std::unique_ptr<IEventHandlerWrapper>>>::iterator handlers_it = handlers_map.find(channel);
if (handlers_it != handlers_map.end()) {
@@ -165,7 +162,7 @@ void EventManager::trigger_event(const EventType & event, int channel) {
}
}
} else {
- std::vector<std::unique_ptr<IEventHandlerWrapper>>& handlers = subscribers[event_type];
+ std::vector<std::unique_ptr<IEventHandlerWrapper>>& handlers = this->subscribers[event_type];
for (std::vector<std::unique_ptr<IEventHandlerWrapper>>::iterator it = handlers.begin(); it != handlers.end();) {
// erases callback if callback function returns true
if ((*it)->exec(event)) {