EnTT 3.14.0
|
Basic dispatcher implementation. More...
#include <dispatcher.hpp>
Public Types | |
using | allocator_type = Allocator |
Allocator type. | |
using | size_type = std::size_t |
Unsigned integer type. | |
Public Member Functions | |
basic_dispatcher () | |
Default constructor. | |
basic_dispatcher (const allocator_type &allocator) | |
Constructs a dispatcher with a given allocator. | |
basic_dispatcher (const basic_dispatcher &)=delete | |
Default copy constructor, deleted on purpose. | |
basic_dispatcher (basic_dispatcher &&other) noexcept | |
Move constructor. | |
basic_dispatcher (basic_dispatcher &&other, const allocator_type &allocator) | |
Allocator-extended move constructor. | |
~basic_dispatcher ()=default | |
Default destructor. | |
basic_dispatcher & | operator= (const basic_dispatcher &)=delete |
Default copy assignment operator, deleted on purpose. | |
basic_dispatcher & | operator= (basic_dispatcher &&other) noexcept |
Move assignment operator. | |
void | swap (basic_dispatcher &other) noexcept |
Exchanges the contents with those of a given dispatcher. | |
constexpr allocator_type | get_allocator () const noexcept |
Returns the associated allocator. | |
template<typename Type > | |
size_type | size (const id_type id=type_hash< Type >::value()) const noexcept |
Returns the number of pending events for a given type. | |
size_type | size () const noexcept |
Returns the total number of pending events. | |
template<typename Type > | |
auto | sink (const id_type id=type_hash< Type >::value()) |
Returns a sink object for the given event and queue. | |
template<typename Type > | |
void | trigger (Type &&value={}) |
Triggers an immediate event of a given type. | |
template<typename Type > | |
void | trigger (const id_type id, Type &&value={}) |
Triggers an immediate event on a queue of a given type. | |
template<typename Type , typename... Args> | |
void | enqueue (Args &&...args) |
Enqueues an event of the given type. | |
template<typename Type > | |
void | enqueue (Type &&value) |
Enqueues an event of the given type. | |
template<typename Type , typename... Args> | |
void | enqueue_hint (const id_type id, Args &&...args) |
Enqueues an event of the given type. | |
template<typename Type > | |
void | enqueue_hint (const id_type id, Type &&value) |
Enqueues an event of the given type. | |
template<typename Type > | |
void | disconnect (Type &value_or_instance) |
Utility function to disconnect everything related to a given value or instance from a dispatcher. | |
template<typename Type > | |
void | disconnect (Type *value_or_instance) |
Utility function to disconnect everything related to a given value or instance from a dispatcher. | |
template<typename Type > | |
void | clear (const id_type id=type_hash< Type >::value()) |
Discards all the events stored so far in a given queue. | |
void | clear () noexcept |
Discards all the events queued so far. | |
template<typename Type > | |
void | update (const id_type id=type_hash< Type >::value()) |
Delivers all the pending events of a given queue. | |
void | update () const |
Delivers all the pending events. | |
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 Type
, listeners are such that they can be invoked with an argument of type Type &
, 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.
Allocator | Type of allocator used to manage memory and elements. |
Definition at line 108 of file dispatcher.hpp.
using entt::basic_dispatcher< Allocator >::allocator_type = Allocator |
Allocator type.
Definition at line 146 of file dispatcher.hpp.
using entt::basic_dispatcher< Allocator >::size_type = std::size_t |
Unsigned integer type.
Definition at line 148 of file dispatcher.hpp.
|
inline |
Default constructor.
Definition at line 151 of file dispatcher.hpp.
|
inlineexplicit |
Constructs a dispatcher with a given allocator.
allocator | The allocator to use. |
Definition at line 158 of file dispatcher.hpp.
|
inlinenoexcept |
Move constructor.
other | The instance to move from. |
Definition at line 168 of file dispatcher.hpp.
|
inline |
Allocator-extended move constructor.
other | The instance to move from. |
allocator | The allocator to use. |
Definition at line 176 of file dispatcher.hpp.
|
inlinenoexcept |
Discards all the events queued so far.
Definition at line 368 of file dispatcher.hpp.
|
inline |
Discards all the events stored so far in a given queue.
Type | Type of event to discard. |
id | Name used to map the event queue within the dispatcher. |
Definition at line 363 of file dispatcher.hpp.
|
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. |
Definition at line 340 of file dispatcher.hpp.
|
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. |
Definition at line 351 of file dispatcher.hpp.
|
inline |
Enqueues an event of the given type.
Type | Type of event to enqueue. |
Args | Types of arguments to use to construct the event. |
args | Arguments to use to construct the event. |
Definition at line 296 of file dispatcher.hpp.
|
inline |
Enqueues an event of the given type.
Type | Type of event to enqueue. |
value | An instance of the given type of event. |
Definition at line 306 of file dispatcher.hpp.
|
inline |
Enqueues an event of the given type.
Type | Type of event to enqueue. |
Args | Types of arguments to use to construct the event. |
id | Name used to map the event queue within the dispatcher. |
args | Arguments to use to construct the event. |
Definition at line 318 of file dispatcher.hpp.
|
inline |
Enqueues an event of the given type.
Type | Type of event to enqueue. |
id | Name used to map the event queue within the dispatcher. |
value | An instance of the given type of event. |
Definition at line 329 of file dispatcher.hpp.
|
inlineconstexprnoexcept |
Returns the associated allocator.
Definition at line 214 of file dispatcher.hpp.
|
inlinenoexcept |
Move assignment operator.
other | The instance to move from. |
Definition at line 195 of file dispatcher.hpp.
|
delete |
Default copy assignment operator, deleted on purpose.
|
inline |
Returns a sink object for the given event and queue.
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.
Type | Type of event of which to get the sink. |
id | Name used to map the event queue within the dispatcher. |
Definition at line 264 of file dispatcher.hpp.
|
inlinenoexcept |
Returns the total number of pending events.
Definition at line 234 of file dispatcher.hpp.
|
inlinenoexcept |
Returns the number of pending events for a given type.
Type | Type of event for which to return the count. |
id | Name used to map the event queue within the dispatcher. |
Definition at line 225 of file dispatcher.hpp.
|
inlinenoexcept |
Exchanges the contents with those of a given dispatcher.
other | Dispatcher to exchange the content with. |
Definition at line 205 of file dispatcher.hpp.
|
inline |
Triggers an immediate event on a queue of a given type.
Type | Type of event to trigger. |
value | An instance of the given type of event. |
id | Name used to map the event queue within the dispatcher. |
Definition at line 285 of file dispatcher.hpp.
|
inline |
Triggers an immediate event of a given type.
Type | Type of event to trigger. |
value | An instance of the given type of event. |
Definition at line 274 of file dispatcher.hpp.
|
inline |
Delivers all the pending events.
Definition at line 385 of file dispatcher.hpp.
|
inline |
Delivers all the pending events of a given queue.
Type | Type of event to send. |
id | Name used to map the event queue within the dispatcher. |
Definition at line 380 of file dispatcher.hpp.