codex
|
A type-safe event listener/dispatcher. More...
#include <event_dispatcher.hpp>
Public Member Functions | |
template<Event E, EventListener< E > L> | |
void | add_listener (L l) |
Adds a callback for a given event type. | |
template<Event E> | |
void | trigger (E e) |
Invokes all listeners associated with the event type. | |
template<Event E, EventListener< E > L> | |
void | add_listener (L l) |
Adds a callback for a given event type. | |
template<Event E> | |
void | trigger (E e) |
Invokes all listeners associated with the event type. | |
Private Member Functions | |
template<Event E> requires std::is_base_of_v< detail::EventListenerVec<E>, EventDispatcher<Es...>> | |
decltype(auto) | vec () |
Helper method to access the storage for a particular event type. | |
template<Event E> requires std::is_base_of_v< detail::EventListenerVec<E>, EventDispatcher<Es...>> | |
decltype(auto) | vec () |
Helper method to access the storage for a particular event type. | |
Additional Inherited Members | |
Private Attributes inherited from codex::detail::EventListenerVec< Es > | |
std::vector< std::function< void(E)> > | v |
A type-safe event listener/dispatcher.
Event listeners for a particular event type can be added via add_listener. Subsequent calls to trigger will invoke each listener for that event type to process it.
Es | Types of events supported by the dispatcher. |
|
inline |
Adds a callback for a given event type.
|
inline |
Adds a callback for a given event type.
Invokes all listeners associated with the event type.
Invokes all listeners associated with the event type.
|
inlineprivate |
Helper method to access the storage for a particular event type.
|
inlineprivate |
Helper method to access the storage for a particular event type.