anatomist
5.0.5
3D neuroimaging data viewer
|
This class can be subclassed to represent an object that the programmer wants to have observed. More...
#include <anatomist/observer/Observable.h>
Public Member Functions | |
Observable () | |
Construct an Observable with zero observers. More... | |
virtual | ~Observable () |
does nothing More... | |
Observer handling | |
void | addObserver (Observer *observer) |
Adds an observer to the set of observers for this object. More... | |
void | deleteObserver (Observer *observer) |
Deletes an observer from the set of observers of this object. More... | |
void | deleteObservers () |
Clears the observer list so that this object no longer has any observers (doesn't call any observer method - see notifyUnregisterObservers() for this ) More... | |
int | countObservers () const |
Returns the number of observers of this object. More... | |
virtual void | notifyObservers (void *arg=0) |
If this object has changed, as indicated by the hasChanged method, then notify all of its observers. More... | |
virtual void | notifyUnregisterObservers () |
Notifies observable destruction to all observers and unregisters them. More... | |
Changed? | |
bool | hasChanged () const |
Tests if this object has changed. More... | |
bool | obsHasChanged (int) const |
only valid during an Observer::update() More... | |
bool | obsHasChanged (const std::string &) const |
only valid during an Observer::update() More... | |
void | setChanged () const |
Indicates that this object has changed. More... | |
Public Member Functions inherited from carto::SharedObject | |
SharedObject () | |
SharedObject (const SharedObject &x) | |
virtual | ~SharedObject () |
SharedObject & | operator= (const SharedObject &) |
bool | testDeletable () |
bool | tryDelete () |
Public Member Functions inherited from carto::WeakObject | |
void | attachWeakPtr (weak_ptr< T > &) const |
void | detachWeakPtr (weak_ptr< T > &) const |
void | attachWeakPtr (weak_shared_ptr< T > &) const |
void | detachWeakPtr (weak_shared_ptr< T > &) const |
virtual | ~WeakObject () |
Public Member Functions inherited from carto::RCObject | |
RCObject () | |
RCObject (const RCObject &) | |
RCObject & | operator= (const RCObject &) |
virtual | ~RCObject () |
Protected Member Functions | |
void | clearChanged () const |
Indicates that this object has no longer changed, or that it has already notified all of its observers of its most recent change. More... | |
void | obsSetChanged (int, bool=true) const |
int-based change flags (use enums to address them) More... | |
void | obsSetChanged (const std::string &, bool=true) const |
string-based change flags More... | |
Protected Member Functions inherited from carto::SharedObject | |
void | disableRefCount () |
Protected Member Functions inherited from carto::WeakObject | |
WeakObject () | |
WeakObject (const WeakObject &) | |
WeakObject & | operator= (const WeakObject &) |
Additional Inherited Members | |
Public Types inherited from carto::RCObject | |
typedef int | RefCounterType |
This class can be subclassed to represent an object that the programmer wants to have observed.
\ An observable object can have one or more observers. After an observable instance changes, an application calling the Observable's notifyObservers method causes all of its observers to be notified of the change by a call to their update method. \ This implementation of an observable is a mere copy of the Java Observable: http://java.sun.com/javase/6/docs/api/java/util/Observable.html
Definition at line 67 of file Observable.h.
anatomist::Observable::Observable | ( | ) |
Construct an Observable with zero observers.
|
virtual |
does nothing
void anatomist::Observable::addObserver | ( | Observer * | observer | ) |
Adds an observer to the set of observers for this object.
observer | an observer to be added |
|
protected |
Indicates that this object has no longer changed, or that it has already notified all of its observers of its most recent change.
This method is called automatically by the notifyObservers methods.
These changed-flags are temporary and are cleared after notifyObservers function is called: do not use them to keep an internal track of things to update (up-to-date flags should be implemented internally by objects)
int anatomist::Observable::countObservers | ( | ) | const |
Returns the number of observers of this object.
void anatomist::Observable::deleteObserver | ( | Observer * | observer | ) |
Deletes an observer from the set of observers of this object.
observer | observer to be deleted |
void anatomist::Observable::deleteObservers | ( | ) |
Clears the observer list so that this object no longer has any observers (doesn't call any observer method - see notifyUnregisterObservers() for this )
|
inline |
Tests if this object has changed.
Definition at line 176 of file Observable.h.
|
virtual |
If this object has changed, as indicated by the hasChanged method, then notify all of its observers.
Then call the clearChanged method to indicate that this object has no longer changed. \ Each Observer.has its update method called.
arg | anything you want to pass to the observers |
Reimplemented in anatomist::ASurface< D >, anatomist::ASurface< 2 >, anatomist::ASurface< 3 >, and anatomist::ATexture.
|
virtual |
Notifies observable destruction to all observers and unregisters them.
bool anatomist::Observable::obsHasChanged | ( | int | ) | const |
only valid during an Observer::update()
bool anatomist::Observable::obsHasChanged | ( | const std::string & | ) | const |
only valid during an Observer::update()
|
protected |
int-based change flags (use enums to address them)
|
protected |
string-based change flags
|
inline |
Indicates that this object has changed.
Definition at line 184 of file Observable.h.
Referenced by anatomist::MObject::eraseObject().