VWLib REFERENCE MANUAL


NAME
vwSubject - An abstract base class for vwLib. vwSubject is the subject component of the Observer Pattern in this library. The abstract vwWidget class, and thus all widgets descend from vwSubject.

HEADER FILE
#include <dependents.h>

PUBLIC METHOD SUMMARY
virtual vwSubject::~vwSubject ( void);
void vwSubject::attach ( vwObserver * concreteObserver);
void vwSubject::detach ( vwObserver * concreteObserver);
inline void * vwSubject::getSubjectData ( void);
inline unsigned long vwSubject::getID ( void);

PROTECTED METHOD SUMMARY
vwSubject::vwSubject ( vwMediator *concreteMediator);
virtual void vwSubect::notify ( void);
inline void vwSubject::setSubjectData ( void * data);

CLASS DESCRIPTION
vwSubject is the abstract subject class of the Observer Pattern on which this Liberia is based. In congruence with a Mediator Pattern concrete mediator who's abstract class is vwMediator, vwSubject facilitates event propagation from its descendent widgets to concrete observers.

METHOD DESCRIPTIONS

   vwSubject() [Protected]
vwSubect ( vwMediator *concreteMediator);

Construct a vwSubject.

*concreteMediator specifies a pointer to the concrete mediator of the Mediator Pattern. Normally there is only one concrete mediator in an application. It is a public derivative of the abstract vwMediator class.

   ~vwSubject()
virtual ~vwSubject ( void);

Destruct an instance. The destructor removes its reference from the concrete mediator's subject list.

   attach()
void attach ( vwObserver * concreteObserver);

Attach a concrete observer to this subject. While an observer is attached, each time this subject's  notify() method is called, the observer's vwObserver::update() method will be called once. The concrete mediator will maintain one list for each subject. There will be no more than one reference to a particular observer maintained for any given subject.

*concreteObserver specifies a  pointer to a public derivative of the abstract vwObserver.

   detach()
void detach ( vwObserver * concreteObserver);

Remove an observer from the subjects list of observers. vwObserver::update() will no longer be called when this subjects notify() method is executed.

*concreteObserver specifies a pointer to a publicly derived  instance of the abstract vwObserver.

    getSubjectData()
inline void * getSubjectData ( void);

Returns a pointer to a subject's data. If not set, returns NULL.

   getID()
virtual unsigned long getID ( void);

Get a subject's ID number. A subject's unique ID value can be used to identify it.

   notify() [Protected]
void notify ( void);

Generate an event. notify() generates a call to vwObserver::update() of all concrete observers that are attached to the subject. This is done at a low level through the concrete vwMediator which maintains subject - observer lists in a Mediator Pattern that handles all bookkeeping for the Observer Pattern.

  setSubjectData() [Protected]
inline void setSubjectData ( void * data);

Set a pointer to data that will be passed to vwObserver::update() of all observers attached to this subject.

*data specifies a void pointer to some memory address. The constructors of certain widgets (e.g., vwSlider) call setSubjectData() with the parameter *data being a pointer to their data value.

SEE ALSO
vwMediator, vwObserver

vrmedlab.jpg (7272 bytes)