![]() |
R-Type
2
Doom but in better
|
A utility class for dispatching and handling game events. More...
#include <EventDispatcher.hpp>
Public Types | |
using | Callback = std::function<void(const GameMessage&)> |
Defines the type for event callbacks. | |
Public Member Functions | |
void | subscribe (Callback callback) |
Subscribes a listener to game events. | |
void | notify (const GameMessage &event) |
Notifies the subscribed listener of an event. | |
A utility class for dispatching and handling game events.
The EventDispatcher
facilitates the subscription and notification of game events using a callback mechanism. It allows a single listener to subscribe to events, which are then forwarded through the provided callback.
Definition at line 12 of file EventDispatcher.hpp.
using EventDispatcher::Callback = std::function<void(const GameMessage&)> |
Defines the type for event callbacks.
A callback is a function that takes a GameMessage
as a parameter.
Definition at line 19 of file EventDispatcher.hpp.
|
inline |
Notifies the subscribed listener of an event.
If a listener is subscribed, this method forwards the given GameMessage
to the listener's callback.
event | The event to be dispatched, represented as a GameMessage . |
Definition at line 39 of file EventDispatcher.hpp.
|
inline |
Subscribes a listener to game events.
This method allows setting a callback function to handle incoming game events.
callback | A function that processes GameMessage events. |
Definition at line 28 of file EventDispatcher.hpp.