
event dispatchers keep a list of registered event listeners that are notified of occuring events. This class provides basic infrastructure common to all such dispatchers for easy dispatcher creation. See the Event documentation for further details.
Since the event listener's callback function must be named differently for each listener class (virtual functions must not be overloaded), the dispatcher needs a way to call a function with an unknown name in a generic way. This is handled through Rly, the relay policy. This can be one of the three event related classes or a separate policy class that implements a static forward function. This function forwards the notification to the correct listener function. An example policy may look as follows:
struct FooRelay { inline static void forward(FooEvent& e, const FooDispatcher::LPtr& l) { l->processFooEvent(e); } };
| Evt | the type of Event the dispatcher passes out | |
| Lst | the listener class to be registered | |
| Rly | the relay policy |
Public Types | |
| typedef Lst * | LPtr |
Public Member Functions | |
| EventDispatcher () | |
| void | fireEvent (Evt &e) const |
| notifies all registered listeners | |
| bool | isMuted () const |
| reflects this dispatcher's muted state. | |
| void | setMuted (bool mute) |
| mutes or un-mutes the dispatcher | |
| virtual | ~EventDispatcher () |
Protected Member Functions | |
| void | add (const LPtr &l) |
| registers a listener | |
| void | remove (const LPtr &l) |
| de-registers a listener. | |
|
|||||
|
|
|
|||||||||
|
|
|
|||||||||
|
|
|
||||||||||
|
registers a listener
|
|
||||||||||
|
notifies all registered listeners
The listeners are called in the order in which they were added.
|
|
|||||||||
|
reflects this dispatcher's muted state.
|
|
||||||||||
|
de-registers a listener.
This listener will no longer notify
|
|
||||||||||
|
mutes or un-mutes the dispatcher Muted dispatchers no longer notify their listeners. |
1.4.3