MxEngine
Public Member Functions | List of all members
MxEngine::EventDispatcher< EventBase > Class Template Reference

#include <EventDispatcher.h>

Public Member Functions

void FlushEvents ()
 
template<typename EventType >
void AddEventListener (const MxString &name, std::function< void(EventType &)> func)
 
template<typename FunctionType >
void AddEventListener (const MxString &name, FunctionType &&func)
 
void RemoveEventListener (const MxString &name)
 
template<typename Event >
void Invoke (Event &event)
 
void AddEvent (UniqueRef< EventBase > event)
 
void InvokeAll ()
 

Detailed Description

template<typename EventBase>
class MxEngine::EventDispatcher< EventBase >

EventDispatcher class is used to handle all events inside MxEngine. Events can either be dispatch for Application (global) or for currently active scene. Note that events are NOT dispatched when developer console is opened and instead sheduled until it close

Member Function Documentation

§ AddEvent()

template<typename EventBase>
void MxEngine::EventDispatcher< EventBase >::AddEvent ( UniqueRef< EventBase >  event)
inline

Adds event to event queue. All such events will be dispatched in next frames in the order they were added

Parameters
eventevent to shedule dispatch

§ AddEventListener() [1/2]

template<typename EventBase>
template<typename EventType >
void MxEngine::EventDispatcher< EventBase >::AddEventListener ( const MxString &  name,
std::function< void(EventType &)>  func 
)
inline

adds new event listener to dispatcher (listener placed in waiting queue until next frame). Note that multiple listeners may have same name. If so, deleting by name will result in removing all of them

Parameters
namename of listener (used for deleting listener)
funclistener callback functor

§ AddEventListener() [2/2]

template<typename EventBase>
template<typename FunctionType >
void MxEngine::EventDispatcher< EventBase >::AddEventListener ( const MxString &  name,
FunctionType &&  func 
)
inline

adds new event listener to dispatcher (listener is placed in waiting queue until next frame). Note that multiple listeners may have same name. If so, deleting by name will result in removing all of them

Parameters
namename of listener (used for deleting listener)
funclistener callback functor

§ FlushEvents()

template<typename EventBase>
void MxEngine::EventDispatcher< EventBase >::FlushEvents ( )
inline

performs cache update, removing events from toRemoveCache list and adding events from toAddCache list

§ Invoke()

template<typename EventBase>
template<typename Event >
void MxEngine::EventDispatcher< EventBase >::Invoke ( Event &  event)
inline

Immediately invokes event of specific type. Note that invokation also forces queues to be invalidated

Parameters
eventevent to dispatch

§ InvokeAll()

template<typename EventBase>
void MxEngine::EventDispatcher< EventBase >::InvokeAll ( )
inline

Invokes all shedules events in the order they were added. Note that invoke also forces queues to be invalidated

§ RemoveEventListener()

template<typename EventBase>
void MxEngine::EventDispatcher< EventBase >::RemoveEventListener ( const MxString &  name)
inline

removes all event listeners by their names (action is placed in waiting queue until next frame)

Parameters
namename of listeners to be deleted

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