Class EventBus

Class Documentation

class legion::core::events::EventBus

Central communication channel for events and messages.

Public Functions

template<typename event_type, typename ...Args, typename = inherits_from<event_type, event<event_type>>>
inline void raiseEvent(Args&&... arguments)

Insert event into bus and notify all subscribers.

Template Parameters
  • event_type: Event type to raise.

Parameters
  • arguments: Arguments to pass to the constructor of the event.

inline void raiseEvent(std::unique_ptr<event_base> &&value)
inline void raiseEventUnsafe(std::unique_ptr<event_base> &&value, id_type id)
template<typename event_type, typename = inherits_from<event_type, event<event_type>>>
inline bool checkEvent() const

Check if an event is active.

Template Parameters
  • event_type: Event type to check for.

template<typename event_type, typename = inherits_from<event_type, event<event_type>>>
inline size_type getEventCount() const

Get the amount of events/messages that are currently in the bus.

Template Parameters
  • event_type: Event type to get the amount of.

template<typename event_type, typename = inherits_from<event_type, event<event_type>>>
inline const event_type &getEvent(index_type index = 0) const

Get a reference to an event/message of a certain index.

Template Parameters
  • event_type: Event type to fetch.

template<typename event_type, typename = inherits_from<event_type, event<event_type>>>
inline const event_type &getLastEvent() const

Get a reference to the most recently raised event of this type.

Template Parameters
  • event_type: Event type to fetch.

template<typename event_type, typename = inherits_from<event_type, event<event_type>>>
inline void clearEvent(index_type index = 0)

Removes a certain event from the bus.

Template Parameters
  • event_type: Event type to clear.

template<typename event_type, typename = inherits_from<event_type, event<event_type>>>
inline void clearLastEvent()

Removes a the most recent event from the bus.

Template Parameters
  • event_type: Event type to clear.

template<typename event_type, typename = inherits_from<event_type, event<event_type>>>
inline void bindToEvent(delegate<void(event_type*)> callback)

Link a callback to an event type in order to get notified whenever one gets raised.

Template Parameters
  • event_type: Event type to subscribe to.

inline void bindToEventUnsafe(id_type id, delegate<void(event_base*)> callback)