HyperspaceExplorer 0.7.1
|
An object that is notified by a Subject it is attached to. More...
#include <Observer.h>
Public Member Functions | |
virtual void | update (std::shared_ptr< const Subject< Parent > > changedSubject)=0 |
An object that is notified by a Subject it is attached to.
After registering with a Subject, an object of this class is notified of any change of state via the update() method.
This class is an abstract class. The update() method must be implemented.
Any Observer must register with its Subject vi Subject::attach().
Example:
class MinxObserver: public Observer<Minx> { virtual void update(const Subject<Minx> *changedSubject) { // do something } }; MinxSubject subject; shared_ptr< Observer<Minx> > observer(new MinxObserver); subject.attach(observer); subject.jinx(); // observer->update() is called