OBSERVER_BASE Class Reference

Base class for an Observer. More...

#include <mi32/observer.h>

Inheritance diagram for OBSERVER_BASE:
Inheritance graph
[legend]

List of all members.

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_BASEoperator= (const OBSERVER_BASE &rhs)

Detailed Description

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.


Constructor & Destructor Documentation

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.


Member Function Documentation

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


The documentation for this class was generated from the following file:

Generated on Sun Oct 7 21:33:42 2012 for TNTsdk 2012 by  doxygen 1.6.1