Base class for objects that can emit events.
More...
#include <EventEmitter.hpp>
|
| EventEmitter () |
| Constructor for the EventEmitter class.
|
virtual | ~EventEmitter () |
| Destructor for the EventEmitter class.
|
unsigned int | addEventListener (const std::string &eventName, EventCallback callback) |
| Adds a new event listener to the object.
|
bool | removeEventListener (unsigned int listenerID) |
| Removes an event listener from the object.
|
|
void | emitEvent (const std::string &eventName, const EventData &data) |
| Emits an event.
|
Base class for objects that can emit events.
◆ addEventListener()
unsigned int switchboard::EventEmitter::addEventListener |
( |
const std::string & | eventName, |
|
|
EventCallback | callback ) |
Adds a new event listener to the object.
- Parameters
-
eventName | The name of the event to listen to. |
callback | The callback function to call when the event is fired. |
- Returns
- The ID of the listener.
◆ emitEvent()
void switchboard::EventEmitter::emitEvent |
( |
const std::string & | eventName, |
|
|
const EventData & | data ) |
|
protected |
Emits an event.
- Parameters
-
eventName | The name of the event to fire. |
data | The data to pass to the event listeners. |
◆ removeEventListener()
bool switchboard::EventEmitter::removeEventListener |
( |
unsigned int | listenerID | ) |
|
Removes an event listener from the object.
- Parameters
-
listenerID | The ID of the listener to remove. |
- Returns
- True if the listener was removed, false if the listener was not found.
The documentation for this class was generated from the following file: