Clementine
|
Basic dispatcher implementation. More...
#include <entt.hpp>
Public Member Functions | |
template<typename Event > | |
auto | sink () |
Returns a sink object for the given event. More... | |
template<typename Event , typename... Args> | |
void | trigger (Args &&... args) |
Triggers an immediate event of the given type. More... | |
template<typename Event > | |
void | trigger (Event &&event) |
Triggers an immediate event of the given type. More... | |
template<typename Event , typename... Args> | |
void | enqueue (Args &&... args) |
Enqueues an event of the given type. More... | |
template<typename Event > | |
void | enqueue (Event &&event) |
Enqueues an event of the given type. More... | |
template<typename Type > | |
void | disconnect (Type &value_or_instance) |
Utility function to disconnect everything related to a given value or instance from a dispatcher. More... | |
template<typename Type > | |
void | disconnect (Type *value_or_instance) |
Utility function to disconnect everything related to a given value or instance from a dispatcher. More... | |
template<typename... Event> | |
void | clear () |
Discards all the events queued so far. More... | |
template<typename Event > | |
void | update () |
Delivers all the pending events of the given type. More... | |
void | update () const |
Delivers all the pending events. More... | |
Basic dispatcher implementation.
A dispatcher can be used either to trigger an immediate event or to enqueue events to be published all together once per tick.
Listeners are provided in the form of member functions. For each event of type Event
, listeners are such that they can be invoked with an argument of type Event &
, no matter what the return type is.
The dispatcher creates instances of the sigh
class internally. Refer to the documentation of the latter for more details.
|
inline |
Discards all the events queued so far.
If no types are provided, the dispatcher will clear all the existing pools.
Event | Type of events to discard. |
|
inline |
Utility function to disconnect everything related to a given value or instance from a dispatcher.
Type | Type of class or type of payload. |
value_or_instance | A valid object that fits the purpose. |
|
inline |
Utility function to disconnect everything related to a given value or instance from a dispatcher.
Type | Type of class or type of payload. |
value_or_instance | A valid object that fits the purpose. |
|
inline |
Enqueues an event of the given type.
An event of the given type is queued. No listener is invoked. Use the update
member function to notify listeners when ready.
Event | Type of event to enqueue. |
Args | Types of arguments to use to construct the event. |
args | Arguments to use to construct the event. |
|
inline |
Enqueues an event of the given type.
An event of the given type is queued. No listener is invoked. Use the update
member function to notify listeners when ready.
Event | Type of event to enqueue. |
event | An instance of the given type of event. |
|
inline |
Returns a sink object for the given event.
A sink is an opaque object used to connect listeners to events.
The function type for a listener is compatible with:
The order of invocation of the listeners isn't guaranteed.
Event | Type of event of which to get the sink. |
|
inline |
Triggers an immediate event of the given type.
All the listeners registered for the given type are immediately notified. The event is discarded after the execution.
Event | Type of event to trigger. |
Args | Types of arguments to use to construct the event. |
args | Arguments to use to construct the event. |
|
inline |
Triggers an immediate event of the given type.
All the listeners registered for the given type are immediately notified. The event is discarded after the execution.
Event | Type of event to trigger. |
event | An instance of the given type of event. |
|
inline |
Delivers all the pending events of the given type.
This method is blocking and it doesn't return until all the events are delivered to the registered listeners. It's responsibility of the users to reduce at a minimum the time spent in the bodies of the listeners.
Event | Type of events to send. |
|
inline |
Delivers all the pending events.
This method is blocking and it doesn't return until all the events are delivered to the registered listeners. It's responsibility of the users to reduce at a minimum the time spent in the bodies of the listeners.