Base class for an Observer. More...
#include <mi32/observer.h>

Public Member Functions | |
| OBSERVER_BASE (const OBSERVER_BASE &rhs) | |
| OBSERVER_BASE (SUBJECTBASE &subject) | |
| virtual | ~OBSERVER_BASE () |
| void | Attach () |
| void | Detach () |
| bool | IsAttached () const |
| virtual void | OnNotify () |
| void | OnSubjectDestroy () |
| OBSERVER_BASE & | operator= (const OBSERVER_BASE &rhs) |
Base class for an Observer.
For simple cases, there is a virtual method Notify() which the SUBJECT can call. For more complicated usage, see the example at the end of this include file.
| OBSERVER_BASE::OBSERVER_BASE | ( | SUBJECTBASE & | subject | ) | [inline] |
Constructor taking a SUBJECT reference.
Will arrange to be notified when subject changes anything
| OBSERVER_BASE::OBSERVER_BASE | ( | const OBSERVER_BASE & | rhs | ) | [inline] |
Copy constructor.
| virtual OBSERVER_BASE::~OBSERVER_BASE | ( | ) | [inline, virtual] |
Destructor.
Remove ourselves from the SUBJECT's observer list. SUBJECT's destructor will call our OnSubjectDestroy method, which will set m_subject to NULL so that we won't try to remove ourselves from a subject that no longer exists.
| void OBSERVER_BASE::Attach | ( | ) | [inline] |
| void OBSERVER_BASE::Detach | ( | ) | [inline] |
| bool OBSERVER_BASE::IsAttached | ( | ) | const [inline] |
| virtual void OBSERVER_BASE::OnNotify | ( | ) | [inline, virtual] |
Virtual method which the SUBJECT will call when it's NotifyObservers() method is called.
If other event handlers are needed, they would be implemented as virtual methods in the OBSERVER-derived class, and the SUBJECT- derived class would be given methods to call them.
| void OBSERVER_BASE::OnSubjectDestroy | ( | ) | [inline] |
Called by m_subject's destructor to tell us it's going away.
(Could be made private if we made SUBJECT a friend)
| OBSERVER_BASE& OBSERVER_BASE::operator= | ( | const OBSERVER_BASE & | rhs | ) | [inline] |
Assignment operator.
Don't bother doing anything unless rhs points to a different SUBJECT
1.6.1