diff options
| author | WBoerenkamps <wrj.boerenkamps@student.avans.nl> | 2024-11-20 18:48:18 +0100 | 
|---|---|---|
| committer | WBoerenkamps <wrj.boerenkamps@student.avans.nl> | 2024-11-20 18:48:18 +0100 | 
| commit | 9f882131f09410113d757d96e5aa0322aa5584bd (patch) | |
| tree | 9ee5d3b3b8e83f3281797ec4c9c4be47dd603848 /src/crepe/api/EventManager.h | |
| parent | 9a46acde813e00e574e70439795dedcdc9a8192a (diff) | |
git remake
Diffstat (limited to 'src/crepe/api/EventManager.h')
| -rw-r--r-- | src/crepe/api/EventManager.h | 19 | 
1 files changed, 9 insertions, 10 deletions
| diff --git a/src/crepe/api/EventManager.h b/src/crepe/api/EventManager.h index eccb0bf..133d72d 100644 --- a/src/crepe/api/EventManager.h +++ b/src/crepe/api/EventManager.h @@ -19,7 +19,6 @@ static constexpr int CHANNEL_ALL = -1;   */  class EventManager {  public: -  	/**       * \brief Get the singleton instance of the EventManager.       *  @@ -39,7 +38,8 @@ public:       * \param channel The channel number to subscribe to (default is 0).       */  	template <typename EventType> -	void subscribe(const EventHandler<EventType> & callback, int channel = CHANNEL_ALL, int priority = 0); +	void subscribe(const EventHandler<EventType> & callback, int channel = CHANNEL_ALL, +				   int priority = 0);  	/**       * \brief Unsubscribe from an event. @@ -76,7 +76,7 @@ public:       * \param channel The channel number for the event (default is 0).       */  	template <typename EventType> -	void queue_event(const EventType & event, int channel = CHANNEL_ALL,int priority = 0); +	void queue_event(const EventType & event, int channel = CHANNEL_ALL, int priority = 0);  	/**       * \brief Dispatch all queued events. @@ -90,8 +90,8 @@ public:       *        */  	void clear(); +  private: -	  	/**       * \brief Default constructor for the EventManager.       *  @@ -99,21 +99,20 @@ private:       */  	EventManager() = default;  	struct QueueEntry { -        	std::unique_ptr<Event> event; +		std::unique_ptr<Event> event;  		int channel = CHANNEL_ALL;  		std::type_index type;  		int priority = 0; -    	}; +	};  	struct CallbackEntry { -        	std::unique_ptr<IEventHandlerWrapper> callback; +		std::unique_ptr<IEventHandlerWrapper> callback;  		int channel = CHANNEL_ALL;  		int priority = 0; -    	}; +	};  	//! The queue of events to be processed.  	std::vector<QueueEntry> events_queue;  	//! Registered event handlers. -	std::unordered_map<std::type_index,std::vector<CallbackEntry>> subscribers; -	 +	std::unordered_map<std::type_index, std::vector<CallbackEntry>> subscribers;  };  } // namespace crepe |