class CAVERNmisc_observer_c

Observer class

Inheritance:


Public Methods

virtual void update (CAVERNmisc_subject_c * )
This method is executed whenever a subject this observer is "watching" calls its notify() method

Documentation

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.

virtual void update(CAVERNmisc_subject_c * )
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.


Direct child classes:
CAVERNdb_sharedState_c
Author:
: cavern@evl
Version:
: 12/1/99

alphabetic index hierarchy of classes


this page has been generated automatically by doc++

(c)opyright by Malte Zöckler, Roland Wunderling
contact: doc++@zib.de