CSL  6.0
csl::Model Class Reference

The Model/Observable/Subject class; instances of its subclasses should send themselves, this->changed(some_data); on "relevant" state changes; the code they inherit (from Model) manages updating the list of observer/dependent objects in that they each receive update(some_data); and can access the model-passed data (the model might pass "this"). More...

#include <CGestalt.h>

+ Inheritance diagram for csl::Model:

Public Member Functions

 Model ()
 
virtual ~Model ()
 constructor More...
 
void attachObserver (Observer *)
 (possibly notify obersvers on my death) More...
 
void detachObserver (Observer *)
 
void changed (void *argument)
 this is what I send to myself to notify my observers; It's not overridden in general. It results in the observers receiving update() calls < override evaluate to filter updates to the observer map More...
 
virtual int evaluate (void *argument)
 

Private Attributes

ObserverVector mObservers
 the private vector of observers More...
 
std::map< int, ObserverVectormObsMap
 the private map-by-key of observers More...
 
bool mHasObservers
 whether there are any observers (for fast checking) More...
 
bool mHasObserverMap
 whether there are any observers (for fast checking) More...
 
float mUpdateTime
 when I last updated More...
 
float mPeriod
 update rate in sec More...
 

Detailed Description

The Model/Observable/Subject class; instances of its subclasses should send themselves, this->changed(some_data); on "relevant" state changes; the code they inherit (from Model) manages updating the list of observer/dependent objects in that they each receive update(some_data); and can access the model-passed data (the model might pass "this").

Note the addition of timers, so observers can request no more than a certain rate of updates.

Definition at line 258 of file CGestalt.h.

Constructor & Destructor Documentation

csl::Model::Model ( )
inline

Definition at line 260 of file CGestalt.h.

virtual csl::Model::~Model ( )
inlinevirtual

constructor

Definition at line 261 of file CGestalt.h.

Member Function Documentation

void Model::attachObserver ( Observer o)

(possibly notify obersvers on my death)

register/remove observers

Definition at line 502 of file CGestalt.cpp.

References csl::logMsg(), csl::Observer::mKey, and csl::Observer::mPeriod.

Referenced by CSLMIDIComponent::CSLMIDIComponent(), and csl::SpatialPanner::setSpeakerLayout().

void Model::detachObserver ( Observer o)
void Model::changed ( void *  argument)

this is what I send to myself to notify my observers; It's not overridden in general. It results in the observers receiving update() calls < override evaluate to filter updates to the observer map

Definition at line 540 of file CGestalt.cpp.

References csl::logMsg().

Referenced by csl::SpeakerLayout::addSpeaker(), csl::MIDIIn::handleIncomingMidiMessage(), and csl::SpeakerLayout::setDefaultSpeakerLayout().

virtual int csl::Model::evaluate ( void *  argument)
inlinevirtual

Reimplemented in csl::MIDIIn.

Definition at line 270 of file CGestalt.h.

Member Data Documentation

ObserverVector csl::Model::mObservers
private

the private vector of observers

Definition at line 270 of file CGestalt.h.

std::map<int, ObserverVector> csl::Model::mObsMap
private

the private map-by-key of observers

Definition at line 274 of file CGestalt.h.

bool csl::Model::mHasObservers
private

whether there are any observers (for fast checking)

Definition at line 275 of file CGestalt.h.

bool csl::Model::mHasObserverMap
private

whether there are any observers (for fast checking)

Definition at line 276 of file CGestalt.h.

float csl::Model::mUpdateTime
private

when I last updated

Definition at line 277 of file CGestalt.h.

float csl::Model::mPeriod
private

update rate in sec

Definition at line 278 of file CGestalt.h.


The documentation for this class was generated from the following files: