ML Reference
ml::EventSource Class Reference

EventSourceBase class adds event listener handling to Base. More...

#include <mlEventSource.h>

Inheritance diagram for ml::EventSource:
ml::Base ml::RefCountedBase

List of all members.

Classes

struct  ListenerEntry
 we use this structure instead of a std::pair to get nicer code

Public Member Functions

 EventSource ()
virtual ~EventSource ()
void addEventListener (BaseEventCallback *cb, void *userData)
 add event listener callback to this Base object - the userData will be the first argument when the callback is called
void removeEventListener (BaseEventCallback *cb, void *userData)
 remove event listener callback from this Base object - arguments must be the same as for the addEventListener call
bool hasEventListeners () const
 check if any event listeners have been added to this Base object; this can be used to skip the sendEvent call (and the potentially expensive building of the event object) altogether

Protected Member Functions

void sendEvent (BaseEvent *event, void *skipListener=NULL)
 Macro for the declaration of the runtime type system methods, defined in mlRuntimeSubClass.h.

Detailed Description

EventSourceBase class adds event listener handling to Base.

Events are derived from BaseEvent.

Definition at line 25 of file mlEventSource.h.


Constructor & Destructor Documentation

ml::EventSource::EventSource ( ) [inline]

Definition at line 28 of file mlEventSource.h.

virtual ml::EventSource::~EventSource ( ) [virtual]

Member Function Documentation

void ml::EventSource::addEventListener ( BaseEventCallback cb,
void *  userData 
)

add event listener callback to this Base object - the userData will be the first argument when the callback is called

bool ml::EventSource::hasEventListeners ( ) const

check if any event listeners have been added to this Base object; this can be used to skip the sendEvent call (and the potentially expensive building of the event object) altogether

void ml::EventSource::removeEventListener ( BaseEventCallback cb,
void *  userData 
)

remove event listener callback from this Base object - arguments must be the same as for the addEventListener call

void ml::EventSource::sendEvent ( BaseEvent event,
void *  skipListener = NULL 
) [protected]

Macro for the declaration of the runtime type system methods, defined in mlRuntimeSubClass.h.

pass event object to all registered listeners, ownership stays with the sender (so you can create the event object on the stack). If skipListener is set to a non-NULL value, the event will not be sent to any listeners that have the same userData set, so you can avoid to be notified of your own changes.


The documentation for this class was generated from the following file: