CARMA C++
|
The Observable class is paired with the Observer class, with the Observable class calls its observableEvent() method to notify all registered Observers. More...
#include <carma/util/Observable.h>
Public Member Functions | |
int | getNumObservers () |
Get the number of registered observers. More... | |
void | notifyObservers () |
Notify all registered Observers, by calling Observer::observerUpdate() More... | |
Observable () | |
Constructor. More... | |
void | registerObserver (Observer &observer) |
Register an Observer object to be notified when event occurs. More... | |
std::vector< int > | registryIds () |
Put all regIDs into a vector. More... | |
std::string | registryToString () |
Put all regIDs into a single line string. More... | |
void | unregisterObserver (Observer &observer) |
Unregister an Observer object. More... | |
virtual | ~Observable () |
Destructor. More... | |
The Observable class is paired with the Observer class, with the Observable class calls its observableEvent() method to notify all registered Observers.
Observers may register once, and only once, with an unlimited number of Observable objects, It is left to the clients to do any resource synchronization. The simplest use of this class is to provide a programmable callback mechanism.
Definition at line 41 of file Observable.h.
carma::util::Observable::Observable | ( | ) |
Constructor.
|
virtual |
Destructor.
int carma::util::Observable::getNumObservers | ( | ) |
Get the number of registered observers.
There is no test for uniqueness; if a single object is registered multiple times it will be counted multiple times.
void carma::util::Observable::notifyObservers | ( | ) |
Notify all registered Observers, by calling Observer::observerUpdate()
void carma::util::Observable::registerObserver | ( | Observer & | observer | ) |
Register an Observer object to be notified when event occurs.
The Observers are notified by calling their observerUpdate() method
ErrorException | if the object is already registered |
observer | Object to notify when event occurs |
std::vector<int> carma::util::Observable::registryIds | ( | ) |
Put all regIDs into a vector.
std::string carma::util::Observable::registryToString | ( | ) |
Put all regIDs into a single line string.
void carma::util::Observable::unregisterObserver | ( | Observer & | observer | ) |
Unregister an Observer object.
observer | Object to unregister |
ErrorException | if the object is not already registered |