EventBroadcaster< TListener > Class Template Reference

Event broadcasting class template. More...

#include <EventBroadcaster.h>

List of all members.

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.

Detailed Description

template<class TListener>
class EventBroadcaster< TListener >

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.


Constructor & Destructor Documentation

template<class TListener>
EventBroadcaster< TListener >::EventBroadcaster (  )  [inline]

Class constructor.

Initializes the event broadcaster class.

template<class TListener>
virtual EventBroadcaster< TListener >::~EventBroadcaster (  )  [inline, virtual]

Class destructor.

Destroys the event broadcaster class.


Member Function Documentation

template<class TListener>
void EventBroadcaster< TListener >::addListener ( TListener *  pListener  )  [inline]

Add new listener.

Adds a new listener of type TListener to the list of event listeners.

Parameters:
pListener Pointer to the event listener class that implements TListener interface.

Reimplemented in NetworkConnection.

template<class TListener>
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().

Parameters:
enumForward Specifies whether the enumeration is in forward direction.
Returns:
Returns true if there is at least one listener to enumerate.
template<class TListener>
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.

template<class TListener>
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.

Returns:
Returns the pointer to the next registered listener object. Returns NULL if there are no more listeners in the list.
template<class TListener>
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.

Parameters:
pListener Pointer to the event listener object implementing TListener interface.
Returns:
Returns true if the listener was deleted successfully.

The documentation for this class was generated from the following file:
Generated on Wed Oct 20 11:13:43 2010 for libspatha by  doxygen 1.6.3