Shadowrun: Awakened 29 September 2011 - Build 871
ObserverCollection.h
Go to the documentation of this file.
00001 #ifndef __OBSERVERCOLLECTION_H
00002 #define __OBSERVERCOLLECTION_H
00003 
00004 #include <list>
00005 
00009 template<class T>
00010 class ObserverCollection
00011 {
00012 protected:
00013     std::list<T*> _listeners;
00014 
00015 public:
00019     void addListener(T* listener)
00020     {
00021         _listeners.push_back(listener);
00022     }
00023 
00027     void removeListener(T* listener)
00028     {
00029         _listeners.remove(listener);
00030     }
00031 
00032     void notify()
00033     {
00034         for(std::list<T*>::iterator it = _listeners.begin(); it != _listeners.end(); it++)
00035             (*it)->update();
00036     }
00037 };
00038 
00039 #endif

Copyright © 2007-2010 by The Shadowrun: Awakened Team. This work is licensed under the GNU Lesser General Public License 3.

GNU Lesser General Public License 3 Sourceforge.net