1 //
2 // Author: Lorenzo Bettini <http://www.lorenzobettini.it>, (C) 2004-2008
3 //
4 // Copyright: See COPYING file that comes with this distribution
5 //
6
7 #ifndef EVENTGENERATOR_H_
8 #define EVENTGENERATOR_H_
9
10 #include <list>
11
13
21 public:
22 void addListener(EventListener *listener) {
23 listeners.push_back(listener);
24 }
25
26 void removeListener(EventListener *listener) {
27 listeners.remove(listener);
28 }
29
30 bool hasListeners() const {
31 return listeners.size();
32 }
33
38 void notify(
const EventType &event) {
39 for (typename std::list<EventListener *>::const_iterator it =
40 listeners.begin(); it != listeners.end(); ++it) {
41 (*it)->notify(event);
42 }
43 }
44 };
45
46 }
47
48 #endif /*EVENTGENERATOR_H_*/
std::list< EventListener * > listeners
the list of listeners
Definition: eventgenerator.h:20
C++ class: doctemplate.h.
Definition: bufferedoutput.cpp:13
void notify(const EventType &event)
Notifies all listeners of a specific event.
Definition: eventgenerator.h:38
A generic event generator, for listeners of type EventListener and events of type EventType...
Definition: eventgenerator.h:18