Event broadcasting class template. More...
#include <EventBroadcaster.h>
Public Member Functions | |
EventBroadcaster () | |
Class constructor. | |
virtual | ~EventBroadcaster () |
Class destructor. | |
void | addListener (TListener *pListener) |
Add new listener. | |
bool | removeListener (TListener *pListener) |
Remove listener. | |
bool | beginEnumListeners (bool enumForward=true) |
Start listener enumeration. | |
TListener * | getNextListener () |
Get next listener. | |
void | endEnumListeners () |
End listener enumeration. |
Event broadcasting class template.
This class is a template for classes that implement event broadcasting to listeners. The template provides methods to manage a list of listeners. The implementation may then enumerate registered listeners and call them when appropriate.
The class takes TListener as a template parameter, which identifies the listener interface being managed by the event broadcaster.
EventBroadcaster< TListener >::EventBroadcaster | ( | ) | [inline] |
Class constructor.
Initializes the event broadcaster class.
virtual EventBroadcaster< TListener >::~EventBroadcaster | ( | ) | [inline, virtual] |
Class destructor.
Destroys the event broadcaster class.
void EventBroadcaster< TListener >::addListener | ( | TListener * | pListener | ) | [inline] |
Add new listener.
Adds a new listener of type TListener to the list of event listeners.
pListener | Pointer to the event listener class that implements TListener interface. |
Reimplemented in NetworkConnection.
bool EventBroadcaster< TListener >::beginEnumListeners | ( | bool | enumForward = true |
) | [inline] |
Start listener enumeration.
Begins enumerating registered listeners. Enumeration is supported in forward and reverse directions. After the call to beginEnumListeners() succeeds, the caller should proceed to getNextListener() and finally endEnumListeners().
enumForward | Specifies whether the enumeration is in forward direction. |
void EventBroadcaster< TListener >::endEnumListeners | ( | ) | [inline] |
End listener enumeration.
Stops enumerating registered listeners. Must be called at the end of enumeration to release the thread safety lock.
TListener* EventBroadcaster< TListener >::getNextListener | ( | ) | [inline] |
Get next listener.
Retrieve the next listener from the list of event listeners. Note beginEnumListeners() must be called at the beginning of enumeration.
bool EventBroadcaster< TListener >::removeListener | ( | TListener * | pListener | ) | [inline] |
Remove listener.
Deletes a listener of type TListener from the list of event listeners. The listener must be previously added by the addListener() call.
pListener | Pointer to the event listener object implementing TListener interface. |