Main Page   Modules   Class Hierarchy   Compound List   File List   Compound Members   File Members   Related Pages   Examples  

misc/observer.cpp

Go to the documentation of this file.
00001 #include "observer.h"
00002 
00008 using namespace std;
00009 
00011 
00012 GltObserverAbstract::GltObserverAbstract()
00013 {
00014 }
00015 
00016 GltObserverAbstract::GltObserverAbstract(const GltObserverAbstract &other)
00017 {
00018 }
00019 
00020 GltObserverAbstract::~GltObserverAbstract() 
00021 {
00022     for (list<GltSubject *>::iterator i=_subjects.begin(); i!=_subjects.end(); i++)
00023         (*i)->_observers.remove(this);
00024     _subjects.clear();
00025 }
00026 
00027 GltObserverAbstract &
00028 GltObserverAbstract::operator=(const GltObserverAbstract &other)
00029 {
00030     return *this;
00031 }
00032 
00033 void 
00034 GltObserverAbstract::observe(GltSubject &subject)
00035 {
00036     subject._observers.push_back(this);
00037     _subjects.push_back(&subject);
00038 }
00039 
00040 void 
00041 GltObserverAbstract::forget(GltSubject &subject)
00042 {
00043     subject._observers.remove(this);
00044     _subjects.remove(&subject);
00045 }
00046 
00048 
00049 GltSubject::GltSubject()  
00050 {
00051 }
00052 
00053 GltSubject::GltSubject(const GltSubject &other)
00054 {
00055 }
00056 
00057 GltSubject::~GltSubject() 
00058 {
00059     for (list<GltObserverAbstract *>::iterator i=_observers.begin(); i!=_observers.end(); i++)
00060         (*i)->_subjects.remove(this);
00061     _observers.clear();
00062 }
00063 
00064 GltSubject &
00065 GltSubject::operator=(const GltSubject &other)
00066 {
00067     return *this;
00068 }
00069 
00070 void 
00071 GltSubject::notify(const void *object)
00072 {
00073     for (list<GltObserverAbstract *>::iterator i=_observers.begin(); i!=_observers.end(); i++)
00074         (*i)->OnNotify(object);
00075 }
00076 

Generated on Tue Nov 5 11:11:05 2002 for GLT by doxygen1.2.18