The class Observable defines a mechanism that allows objects to be notified of changes to the specified properties of other objects. More...
#include <Observable.h>
Public Member Functions | |
virtual | ~Observable () |
virtual void | addObserver (string aKey, Observer &o) |
Adds an entry to the receiver’s dispatch table with an observer, for a notifications restricted to key. | |
virtual void | removeObserver (string aKey, Observer &o) |
Removes matching entries from the receiver’s dispatch table for the specified keys. | |
virtual void | removeAllObservers () |
Remove all observer from the dispatch table. | |
virtual int | countObservers () |
Returns the number of keys observed. | |
Protected Member Functions | |
virtual void | willChangeValueForKey (string aKey) |
Invoked to inform the receiver that the value of a given property is about to change. | |
virtual void | didChangevalueForKey (string aKey) |
Invoked to inform the receiver that the value of a given property has changed. | |
Private Attributes | |
map< string, set< Observer * > > | observers |
Association between the key and the list of observers. |
The class Observable defines a mechanism that allows objects to be notified of changes to the specified properties of other objects.
You can observe any object properties including simple attributes. Observers are informed of the type of change made — as well as which objects are involved in the change.
virtual Observable::~Observable | ( | ) | [inline, virtual] |
void Observable::addObserver | ( | std::string | aKey, | |
Observer & | o | |||
) | [virtual] |
Adds an entry to the receiver’s dispatch table with an observer, for a notifications restricted to key.
[in] | aKey | The name of the notification for which to register the observer |
[in] | o | Object registering as an observer. This value must not be NULL. |
References observers.
int Observable::countObservers | ( | ) | [virtual] |
void Observable::didChangevalueForKey | ( | string | aKey | ) | [protected, virtual] |
Invoked to inform the receiver that the value of a given property has changed.
References observers.
void Observable::removeAllObservers | ( | ) | [virtual] |
Remove all observer from the dispatch table.
References observers.
void Observable::removeObserver | ( | string | aKey, | |
Observer & | o | |||
) | [virtual] |
void Observable::willChangeValueForKey | ( | string | aKey | ) | [protected, virtual] |
Invoked to inform the receiver that the value of a given property is about to change.
References observers.
map<string, set<Observer *> > Observable::observers [private] |
Association between the key and the list of observers.
Referenced by addObserver(), countObservers(), didChangevalueForKey(), removeAllObservers(), removeObserver(), and willChangeValueForKey().