CSL  5.2
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:

List of all members.

Public Member Functions

 Model ()
virtual ~Model ()
 constructor
void attachObserver (Observer *)
 (possibly notify obersvers on my death)
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
virtual int evaluate (void *argument)

Private Attributes

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

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 247 of file CGestalt.h.


Constructor & Destructor Documentation

csl::Model::Model ( )
inline

Definition at line 249 of file CGestalt.h.

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

constructor

Definition at line 250 of file CGestalt.h.


Member Function Documentation

void Model::attachObserver ( Observer o)

(possibly notify obersvers on my death)

register/remove observers

Definition at line 491 of file CGestalt.cpp.

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

Referenced by 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 529 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 259 of file CGestalt.h.


Member Data Documentation

ObserverVector csl::Model::mObservers
private

the private vector of observers

Definition at line 259 of file CGestalt.h.

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

the private map-by-key of observers

Definition at line 263 of file CGestalt.h.

bool csl::Model::mHasObservers
private

whether there are any observers (for fast checking)

Definition at line 264 of file CGestalt.h.

bool csl::Model::mHasObserverMap
private

whether there are any observers (for fast checking)

Definition at line 265 of file CGestalt.h.

float csl::Model::mUpdateTime
private

when I last updated

Definition at line 266 of file CGestalt.h.

float csl::Model::mPeriod
private

update rate in sec

Definition at line 267 of file CGestalt.h.


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