codex
Loading...
Searching...
No Matches
codex::EventDispatcher< Es > Class Template Reference

A type-safe event listener/dispatcher. More...

#include <event_dispatcher.hpp>

Inheritance diagram for codex::EventDispatcher< Es >:
Collaboration diagram for codex::EventDispatcher< Es >:

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
 

Detailed Description

template<Event ... Es>
class codex::EventDispatcher< Es >

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.

Template Parameters
EsTypes of events supported by the dispatcher.

Member Function Documentation

◆ add_listener() [1/2]

template<Event ... Es>
template<Event E, EventListener< E > L>
void codex::EventDispatcher< Es >::add_listener ( L l)
inline

Adds a callback for a given event type.

Here is the call graph for this function:

◆ add_listener() [2/2]

template<Event ... Es>
template<Event E, EventListener< E > L>
void codex::EventDispatcher< Es >::add_listener ( L l)
inline

Adds a callback for a given event type.

Here is the call graph for this function:

◆ trigger() [1/2]

template<Event ... Es>
template<Event E>
void codex::EventDispatcher< Es >::trigger ( E e)
inline

Invokes all listeners associated with the event type.

Here is the call graph for this function:

◆ trigger() [2/2]

template<Event ... Es>
template<Event E>
void codex::EventDispatcher< Es >::trigger ( E e)
inline

Invokes all listeners associated with the event type.

Here is the call graph for this function:

◆ vec() [1/2]

template<Event ... Es>
template<Event E>
requires std::is_base_of_v< detail::EventListenerVec<E>, EventDispatcher<Es...>>
decltype(auto) codex::EventDispatcher< Es >::vec ( )
inlineprivate

Helper method to access the storage for a particular event type.

Here is the caller graph for this function:

◆ vec() [2/2]

template<Event ... Es>
template<Event E>
requires std::is_base_of_v< detail::EventListenerVec<E>, EventDispatcher<Es...>>
decltype(auto) codex::EventDispatcher< Es >::vec ( )
inlineprivate

Helper method to access the storage for a particular event type.


The documentation for this class was generated from the following files: