Observable

The class Observable provides a minimal implementation needed for an observable in the observer pattern.

An observable can have more than one observer.

When an important value changes in the observable, it sends notifications to all its observers.

Usually Observable serves as a parent class for multiple inheritance, e.g.

class MultiEvaluator : public Evaluator<T>, public Observable
Code:

Public Methods

constructor

Observable();

The constructor does nothing.

addObserver

void addObserver(Observer *pObs);
pObs

Observer object to be added to observer list.

notifyObservers

void notifyObservers(int iType, const void *pCom);
iType

Type of event.

pCom

A pointer to any kind of data which might be needed.

Notifies all Observer objects by calling their notify method, passing this as the first parameter:

m_vObservers[i]->notify(this, iType, pCom)