CARMA C++
carma::util::Observable Class Reference

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>

Inheritance diagram for carma::util::Observable:
carma::util::PhaseSwitchingImpl carma::correlator::obsRecord2::DefaultCorrControl carma::loberotator::Loberotator

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...
 

Detailed Description

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.

Constructor & Destructor Documentation

carma::util::Observable::Observable ( )

Constructor.

virtual carma::util::Observable::~Observable ( )
virtual

Destructor.

Member Function Documentation

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

Exceptions
ErrorExceptionif the object is already registered
Parameters
observerObject 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.

Parameters
observerObject to unregister
Exceptions
ErrorExceptionif the object is not already registered
See Also
registerObserver

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