HyperspaceExplorer 0.7.1
|
An object telling its state changes to all attached Observer s. More...
#include <Observer.h>
Classes | |
struct | Impl |
Public Member Functions | |
virtual void | attach (std::shared_ptr< Observer< Parent > > observer) |
virtual void | detach (std::shared_ptr< Observer< Parent > > observer) |
Protected Member Functions | |
virtual void | notify () |
Private Attributes | |
std::shared_ptr< Impl > | pImpl_ |
An object telling its state changes to all attached Observer s.
An Observer can register itself for updates on the Subject's state change by calling attach() and deregister with detach().
Whenever the implementing Subject wants to update the registered Observer s of its changed state, it must call the notify() method.
This class is meant to be used as a base class for making a Subject out of a arbitrary class, without intrusion to the original class. The final implementation must insert calls to notify() wherever appropriate.
Example:
class Minx { void jinx(); }; class MinxSubject: public Subject<Minx> { void jinx() { Minx::jinx(); notify(); } }