Templates::Observable< T > Class Template Reference

Implementation of a generic "typed" observer (observable part). More...

#include <observable.h>

List of all members.

Public Member Functions

 Observable (T *self)
 Constructor.
virtual ~Observable ()
 Destructor.
void addObserver (Observer< T > *observer)
 Adds a new observer to the list of observers.
void deleteObserver (Observer< T > *observer)
 Deletes selected observer from the list of observers.
void cleanObservers ()
 Deletes all observers.
void notifyObservers ()
 Notifies all stored observers by calling Observer::update() on them.

Private Types

typedef std::deque< Observer
< T > * > 
ObserverContainer
 Type of a container to store observers.

Private Attributes

T * _self
 Actual object that will be passed to Observer::update() calls.
ObserverContainer _observers
 Stored observers.


Detailed Description

template<class T>
class Templates::Observable< T >

Implementation of a generic "typed" observer (observable part).

Implements "observer" design pattern.

Usage:

 class View: public Observable<View>
 {
     private:
         std::string _name;
     public:
         View(std::string name): Observable<View>(this), _name(name) {}
         ~View() {}
         std::string getName() {return _name;}
 };

See also:
Observer

Member Typedef Documentation

template<class T>
typedef std::deque<Observer<T> *> Templates::Observable< T >::ObserverContainer [private]

Type of a container to store observers.


Constructor & Destructor Documentation

template<class T>
Templates::Observable< T >::Observable ( T *  self  )  [inline]

Constructor.

Parameters:
[in] self Object that will be passed to Observer::update() calls.

template<class T>
virtual Templates::Observable< T >::~Observable (  )  [inline, virtual]

Destructor.


Member Function Documentation

template<class T>
void Templates::Observable< T >::addObserver ( Observer< T > *  observer  )  [inline]

Adds a new observer to the list of observers.

Parameters:
[in] observer Observer to be added.

template<class T>
void Templates::Observable< T >::deleteObserver ( Observer< T > *  observer  )  [inline]

Deletes selected observer from the list of observers.

Parameters:
[in] observer Observer to be deleted.

template<class T>
void Templates::Observable< T >::cleanObservers (  )  [inline]

Deletes all observers.

template<class T>
void Templates::Observable< T >::notifyObservers (  )  [inline]

Notifies all stored observers by calling Observer::update() on them.

See also:
Observer::update()


Member Data Documentation

template<class T>
T* Templates::Observable< T >::_self [private]

Actual object that will be passed to Observer::update() calls.

Referenced by Templates::Observable< Camera >::notifyObservers().

template<class T>
ObserverContainer Templates::Observable< T >::_observers [private]


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

Generated on Sat Dec 20 19:21:24 2008 for PGR2008 by  doxygen 1.5.6