#include <broadcaster.hh>
Inheritance diagram for lestes::std::broadcaster< T, Y >:

Public Member Functions | |
| void | broadcast (ptr< T > what) |
| Inform the listeners, that the event has occured on the parameter. | |
| void | attach (ptr< broadcast_listener< Y > > listener) |
| Register with the broadcaster to listen for the events. | |
Static Public Member Functions | |
| static ptr< broadcaster< T, Y > > | create () |
| Create the broadcaster/event. | |
Protected Member Functions | |
| void | gc_mark () |
| Marks the keystone. | |
| broadcaster () | |
Private Attributes | |
| srp< list< srp< broadcast_listener< Y > > > > | listeners |
The concept of broadcasting is very similar to the concept of events. At a certain point of the program's run there occurs an important event. Such events can be divided into several categories. The first category of events, and by far the most numerous, is the category that encompasses all events that spring from a single source. These events are represented by the class event, q.v. The second category consists of events, that affect an object of a given type. These events could represent the creation / alteration / destruction of an object. The second category of events need not necesarily come from a single source. The remaining kinds of events are not discussed here.
The second category of events, i.e. the events affecting a single object, can be handled by a simple means: all parties interested in the event would enqueue themselves in a designated place. Then, at the moment of the event, the designated place will be accessed and all enqueued listeners would be notified. The mechanics involved are the same as for the first category. However, the affected object shall be announced to the listeners as well.
Definition at line 60 of file broadcaster.hh.
| lestes::std::broadcaster< T, Y >::broadcaster | ( | ) | [inline, protected] |
| void lestes::std::broadcaster< T, Y >::broadcast | ( | ptr< T > | what | ) | [inline] |
Inform the listeners, that the event has occured on the parameter.
Definition at line 63 of file broadcaster.hh.
00064 { 00065 typename list < srp < broadcast_listener < Y > > >::iterator it = listeners->begin(), 00066 end = listeners->end(); 00067 for ( ; it != end ; ++it) { 00068 (*it)->run(what); 00069 } 00070 }
| void lestes::std::broadcaster< T, Y >::attach | ( | ptr< broadcast_listener< Y > > | listener | ) | [inline] |
Register with the broadcaster to listen for the events.
Definition at line 73 of file broadcaster.hh.
00074 { 00075 listeners->push_back(listener); 00076 }
| static ptr< broadcaster < T, Y > > lestes::std::broadcaster< T, Y >::create | ( | void | ) | [inline, static] |
| void lestes::std::broadcaster< T, Y >::gc_mark | ( | void | ) | [inline, protected, virtual] |
Marks the keystone.
Marks all directly reachable parts of the class. The method must be overriden for each inherited class. It should contain abc.gc_mark() for each field abc of the inherited class and call to gc_mark() of the direct ancestor of the class. Does nothing for keystone, only stops processing of ancestors.
Reimplemented from lestes::std::mem::keystone.
Definition at line 84 of file broadcaster.hh.
00085 { 00086 listeners.gc_mark(); 00087 object::gc_mark(); 00088 }
srp< list < srp < broadcast_listener < Y > > > > lestes::std::broadcaster< T, Y >::listeners [private] |
Definition at line 94 of file broadcaster.hh.
1.5.1-20070107