template class for subjects (cfr. Observer Design Pattern). More...
#include <observer.hh>
Public Member Functions | |
virtual void | attach (observer< observed_subject > &o) |
Attach a new observer to this subject. | |
virtual void | detach (observer< observed_subject > &o) |
Detach a new observer to this subject. | |
virtual void | notify () |
Notify all attached observers. | |
virtual | ~subject () |
Protected Member Functions | |
subject () | |
Protected Attributes | |
std::set< observer < observed_subject > * > | observers_m |
template class for subjects (cfr. Observer Design Pattern).
You must declare the subject of the observations with:
class my_observed_sbj : public subject<my_observed_sbj>
Than you should call notify() manually or automatically from every method that changes the subject status.
Only attached observers (cfr. attach() and detach() methods) will be notified.
Definition at line 83 of file observer.hh.
virtual mets::subject< observed_subject >::~subject | ( | ) | [inline, virtual] |
Definition at line 87 of file observer.hh.
mets::subject< observed_subject >::subject | ( | ) | [protected] |
Definition at line 146 of file observer.hh.
void mets::subject< observed_subject >::attach | ( | observer< observed_subject< observed_subject > > & | o | ) | [virtual] |
Attach a new observer to this subject.
o,: | a new observer for this subject. if the observer was already present nothing happens. |
Definition at line 151 of file observer.hh.
void mets::subject< observed_subject >::detach | ( | observer< observed_subject< observed_subject > > & | o | ) | [virtual] |
Detach a new observer to this subject.
o,: | observer to detach from this subject. if the observer "o" was not present nothing happens. |
Definition at line 156 of file observer.hh.
void mets::subject< observed_subject >::notify | ( | ) | [virtual] |
Notify all attached observers.
When this method is called every observed_subject::update method is called and "this" subject is passed as a param.
Definition at line 161 of file observer.hh.
std::set<observer<observed_subject>*> mets::subject< observed_subject >::observers_m [protected] |
Definition at line 112 of file observer.hh.