13 #include "SubjectObserver.h"
23 for (ObserverVec::iterator it=mObservers.begin(); it!=mObservers.end(); ++it) {
24 (*it)->forgetSubject(
this);
32 ObserverVec::iterator where = find(mObservers.begin(), mObservers.end(), obs);
33 if (where==mObservers.end()) {
34 mObservers.push_back(obs);
37 cout <<
"Subject::attach(). ERROR:\t"
38 <<
"observer already known to subject"<<endl;
46 ObserverVec::iterator where = find(mObservers.begin(), mObservers.end(), obs);
47 if (where!=mObservers.end()) {
48 mObservers.erase(where);
51 cout <<
"Subject::detach(). ERROR:\t"
52 <<
"observer not known to subject"<<endl;
57 void Subject::notify()
60 for (ObserverVec::iterator it=mObservers.begin(); it!=mObservers.end(); ++it)
68 Observer::Observer(
Subject * subject)
75 void Observer::changed(
Subject* changedSubject)