|
CSL
6.0
|
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, ObserverVector > | mObsMap |
| 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... | |
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.
|
inline |
Definition at line 260 of file CGestalt.h.
|
inlinevirtual |
constructor
Definition at line 261 of file CGestalt.h.
| 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 | ) |
Definition at line 518 of file CGestalt.cpp.
References csl::logMsg().
Referenced by csl::SpatialPanner::setSpeakerLayout(), and csl::SpatialPanner::~SpatialPanner().
| 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().
|
inlinevirtual |
Reimplemented in csl::MIDIIn.
Definition at line 270 of file CGestalt.h.
|
private |
the private vector of observers
Definition at line 270 of file CGestalt.h.
|
private |
the private map-by-key of observers
Definition at line 274 of file CGestalt.h.
|
private |
whether there are any observers (for fast checking)
Definition at line 275 of file CGestalt.h.
|
private |
whether there are any observers (for fast checking)
Definition at line 276 of file CGestalt.h.
|
private |
when I last updated
Definition at line 277 of file CGestalt.h.
|
private |
update rate in sec
Definition at line 278 of file CGestalt.h.