#include <glpublisher.h>
Public Types | |
|
typedef std::set< LISTENER_CLASS * >::const_iterator | const_iterator |
| Used to iterate through the listeners. | |
Public Member Functions | |
| void | AddListener (LISTENER_CLASS *add) |
| Add a listener. | |
| void | RemoveListener (LISTENER_CLASS *remove) |
| Remove a listener. | |
| const_iterator | begin () |
| An iterator for the publisher to emit messages. | |
| const_iterator | end () |
| An iterator for the publisher to emit messages. | |
If a publisher is deleted, it will clear the pointers to its listener, and if a listener is deleted it will clear the pointes to its publisher. Therefore they can have independent lifespans.
A publisher is aggregated into the class that wants to publish:
class Switch
{
Publisher<SwitchListener> publish;
}
| const_iterator grinliz::Publisher< LISTENER_CLASS >::begin | ( | ) | [inline] |
An iterator for the publisher to emit messages.
The code usually looks like:
for( Publisher<SwitchListener>::const_iterator it = publish.begin();
it != publish.end();
++it )
{
(*it)->Click();
}
| void grinliz::Publisher< LISTENER_CLASS >::RemoveListener | ( | LISTENER_CLASS * | remove | ) | [inline] |
Remove a listener.
This is safe to call at any time, even during a callback.
1.4.7