Main Page   Class Hierarchy   Compound List   File List   Compound Members  

CAVERNmisc_observer_c Class Reference

#include <CAVERNmisc_observer_c.hxx>

Inheritance diagram for CAVERNmisc_observer_c::

CAVERNdb_sharedState_c List of all members.

Public Methods

virtual ~CAVERNmisc_observer_c ()
virtual void update (CAVERNmisc_subject_c *)=0

Protected Methods

 CAVERNmisc_observer_c ()

Detailed Description

Observer class. This is used in conjunction with a CAVERNmisc_subject_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_observer_c::update ( CAVERNmisc_subject_c * subj ) [pure virtual]
 

This method is executed whenever a subject this observer is "watching" calls its notify() method. You can think of this as the equivalent of a callback function. This is a pure virtual function that should be implemented by classes that inherit from the observer.

Parameters:
CAVERnmisc_subject_c   This is a pointer to the subject that woke us up. We can then access its public member variables and even execute its public methods.

Reimplemented in CAVERNdb_sharedState_c.


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