EventManager Class
An abstract EventManager managing the buffering and dispatching of events, acting as a central hub for event management. More...
Declaration
Derived Classes
| class | BasicEventManager |
|
Basic implementation of the EventManager. More... | |
Public Constructors Index
| EventManager (std::unique_ptr< EventQueue > eventQueue, std::unique_ptr< Dispatcher > dispatcher) | |
|
Creates a new EventManager using the specified EventQueue and Dispatcher. More... | |
Protected Constructors Index
| EventManager ()=default | |
Public Destructor Index
| ~EventManager ()=default | |
Public Member Functions Index
| EventManager & | post (std::unique_ptr< const Event > event) |
|
Posts the event to the queue using the APPEND policy, passing ownership of the event to the underlying queue. More... | |
| EventManager & | post (std::unique_ptr< const Event > event, PostPolicy policy) |
|
Posts the event to the queue, passing ownership of the event to the underlying queue. More... | |
| EventManager & | post (std::unique_ptr< const Event > event, PostPolicy policy, const std::function< bool(const std::unique_ptr< const Event > &event, const std::unique_ptr< const Event > &evt)> &func)=0 |
|
Posts the event to the underlying EventQueue using the specified policy and the specified func. More... | |
| EventManager & | dispatchAll ()=0 |
|
Dispatches all events currently held in the event queue. More... | |
template <typename EventType> | |
| EventManager & | subscribe (std::function< void(const EventType &)> callback) |
|
Subscribes a callback to the specified EventType. More... | |
| Dispatcher & | dispatcher () const noexcept |
|
Returns a reference to the dispatcher used with this EventManager. More... | |
Protected Member Attributes Index
| std::unique_ptr< EventQueue > | eventQueue_ |
|
A unique_ptr to the EventQueue this EventManager owns. More... | |
| std::unique_ptr< Dispatcher > | dispatcher_ |
|
A unique_ptr to the Dispatcher this EventManager owns. More... | |
Protected Static Attributes Index
| static const helios::util::log::Logger & | logger_ = helios::util::log::LogManager::loggerForScope(HELIOS_LOG_SCOPE) |
Description
An abstract EventManager managing the buffering and dispatching of events, acting as a central hub for event management.
Concrete implementations take care of `dispatchAll()`, that is, the logic for dispatching all events to the subscribed callbacks.
Definition at line 56 of file EventManager.ixx.
Public Constructors
EventManager()
| inline explicit |
Creates a new EventManager using the specified EventQueue and Dispatcher.
The EventManger takes onwership of the EventQueue and the Dispatcher.
- Parameters
-
eventQueue dispatcher
Definition at line 86 of file EventManager.ixx.
References dispatcher, dispatcher_ and eventQueue_.
Protected Constructors
EventManager()
| protected default |
Definition at line 72 of file EventManager.ixx.
Referenced by helios::event::BasicEventManager::BasicEventManager, helios::event::BasicEventManager::dispatchAll, dispatchAll, helios::event::BasicEventManager::post, post, post, post and subscribe.
Public Destructor
~EventManager()
| virtual default |
Definition at line 76 of file EventManager.ixx.
Public Member Functions
dispatchAll()
|
Dispatches all events currently held in the event queue.
This method retrieves and removes events one by one from the underlying `EventQueue`, passing ownership to the underlying Dispatcher.
- Returns
Definition at line 161 of file EventManager.ixx.
Reference EventManager.
dispatcher()
| inline nodiscard noexcept |
Returns a reference to the dispatcher used with this EventManager.
Provides direct access to the dispatcher, allowing for modification of the Dispatcher, e.g. managing subscriptions.
- Returns
Definition at line 191 of file EventManager.ixx.
Reference dispatcher_.
Referenced by helios::event::BasicEventManager::BasicEventManager and EventManager.
post()
| inline |
Posts the event to the queue using the APPEND policy, passing ownership of the event to the underlying queue.
Calling this function is functionally identical to calling post() with the second argument set to APPEND.
- Parameters
-
event The event to post to the EventQueue.
- Returns
Definition at line 106 of file EventManager.ixx.
References helios::event::APPEND, EventManager and post.
post()
| inline |
Posts the event to the queue, passing ownership of the event to the underlying queue.
Calling this function is identical to calling post() with the third argument func set to nullptr, relying on the default implementations.
- Parameters
-
event The event to post to the EventQueue.
policy The policy to use for posting the event.
- Returns
Definition at line 123 of file EventManager.ixx.
References EventManager, logger_ and post.
post()
|
Posts the event to the underlying EventQueue using the specified policy and the specified func.
Implementing classes are responsible to treating func according to the specified policy, e.g. APPEND for adding the event to the queue, LATEST_WINS for removing a particular event in favor of the submitted event.
- Parameters
-
event A unique_ptr to the event to be posted. Will be the first argument passed to func.
policy The post policy for the event (
- See Also
- Parameters
-
func The function used with the PostPolicy.
- Returns
Definition at line 144 of file EventManager.ixx.
Reference EventManager.
subscribe()
| inline |
Subscribes a callback to the specified EventType.
Delegates to the subscribe() method of the underlying dispatcher.
- Template Parameters
-
EventType The specific tyoe of the event to subscribe to.
- Parameters
-
callback The callback function that should be called when an event of the specific type is triggered.
- Returns
Definition at line 176 of file EventManager.ixx.
References dispatcher_ and EventManager.
Protected Member Attributes
dispatcher_
| protected |
A unique_ptr to the Dispatcher this EventManager owns.
Definition at line 70 of file EventManager.ixx.
Referenced by helios::event::BasicEventManager::dispatchAll, dispatcher, EventManager and subscribe.
eventQueue_
| protected |
A unique_ptr to the EventQueue this EventManager owns.
Definition at line 65 of file EventManager.ixx.
Referenced by helios::event::BasicEventManager::dispatchAll, EventManager and helios::event::BasicEventManager::post.
Protected Static Attributes
logger_
| protected static |
Definition at line 60 of file EventManager.ixx.
Referenced by post.
The documentation for this class was generated from the following file:
Generated via doxygen2docusaurus 2.0.0 by Doxygen 1.15.0.