Main Page   Class Hierarchy   Compound List   File List   Compound Members  

CAVERNmisc_subject_c Class Reference

#include <CAVERNmisc_observer_c.hxx>

Inheritance diagram for CAVERNmisc_subject_c::

CAVERNdb_client_c List of all members.

Public Methods

virtual ~CAVERNmisc_subject_c ()
virtual void attach (CAVERNmisc_observer_c *)
virtual void detach (CAVERNmisc_observer_c *)
virtual void notify ()

Private Attributes

list<CAVERNmisc_observer_c *> m_ListOfObservers

Detailed Description

Subject class. This is used in conjunction with a CAVERNmisc_observer_c class.

What is it for? The subject-observer design pattern is an object oriented alternative to callback functions. We can have multiple observers "watch" a single subject. An observer begins to watch a subject when the subject makes an "attach(&observer)" call. Everytime the subject calls its notify() method, all observers that are watching it will react by calling their update() method.

We do not instantiate the CAVERNmisc_subject_c and the CAVERNmisc_observer_c. Instead, the API user creates classes that inherit the properties of these two superclasses. The class that inherits the observer class properties should implement the update() method. The update method is a pure virtual function. Not implementing it would result in a compiler error.

@author: cavern@evl

@version: 12/1/99


Member Function Documentation

void CAVERNmisc_subject_c::attach ( CAVERNmisc_observer_c * o ) [inline, virtual]
 

Subject calls attach(&observer) to register the observer. After this, everytime the subject calls its notify() method, the registered observer reacts accordingly by calling its update() method.

Parameters:
CAVERNmisc_observer_c   A pointer to the observer we want to register

void CAVERNmisc_subject_c::detach ( CAVERNmisc_observer_c * o ) [inline, virtual]
 

Subject calls detach(&observer) to DEregister the observer.

Parameters:
CAVERNmisc_observer_c   A pointer to the observer we want to DEregister

void CAVERNmisc_subject_c::notify ( ) [inline, virtual]
 

Subject calls notify() to tell all watching observers to react accoringly. (Each watching observer will call its update method.)


The documentation for this class was generated from the following file:
Generated at Mon Jul 2 14:24:43 2001 for CAVERNsoft by doxygen1.2.8-20010617 written by Dimitri van Heesch, © 1997-2001