User Manual, Developers Guide and API Documentation

wns::Observer< NOTIFICATIONINTERFACE > Class Template Reference

An observer to a subject. More...

#include <Observer.hpp>

Inherits wns::ObserverInterface< NOTIFICATIONINTERFACE >< NOTIFICATIONINTERFACE >.

Inherited by lte::controlplane::flowmanagement::flowhandler::FlowHandler, ofdmaphy::Station, wns::events::scheduler::Monitor, and wns::probe::bus::detail::ObserverPimpl.

Collaboration diagram for wns::Observer< NOTIFICATIONINTERFACE >:

Collaboration graph
[legend]

List of all members.

Public Types

typedef NOTIFICATIONINTERFACE NotificationInterface
 The NotificationInterface used by Observer.
typedef ObserverInterface
< NotificationInterface
ObserverType
 Our interface.
typedef SubjectInterface
< ObserverType
SubjectType
 The SubjectInterface using the same NotificationInterface.

Public Member Functions

 Observer (const Observer &other)
 The copy obseves the same subjects as the original.
 Observer ()
 Default constructor.
Observeroperator= (const Observer &other)
 Remove own subjects, obseve new subjects.
void startObserving (SubjectType *subject)
 Nicer to read: oberserver->startObserving(subject);.
void stopObserving (SubjectType *subject)
 Nicer to read: oberserver->stopObserving(subject);.
virtual ~Observer ()
 Detaches itself from every Subject it is attached to.

Private Types

typedef std::list< SubjectType * > SubjectContainer

Private Member Functions

virtual void addSubject (SubjectType *subject)
template<typename FUNCTOR>
FUNCTOR forEachSubject (const FUNCTOR &functor)
 Execute functor on each subject.
virtual void removeSubject (SubjectType *subject)

Private Attributes

SubjectContainer subjects
 Collection of registered subjects.


Detailed Description

template<typename NOTIFICATIONINTERFACE>
class wns::Observer< NOTIFICATIONINTERFACE >

Author:
Marc Schinnenburg <marc@schinnenburg.com>

Swen Kuehnlein

Parameters:
NOTIFICATIONINTERFACE The notification interface of the observer.
This implementation of ObserverInterface detaches itself from all subjects it is attached to on its destruction. It will receive notifications from the subject via the NOTIFICATIONINTERFACE it (indirectly) derives from.

See also:
Subject, ObserverInterface, SubjectInterface.

Definition at line 54 of file Observer.hpp.


Member Typedef Documentation

template<typename NOTIFICATIONINTERFACE>
typedef NOTIFICATIONINTERFACE wns::Observer< NOTIFICATIONINTERFACE >::NotificationInterface

The NotificationInterface used by Observer.

Definition at line 63 of file Observer.hpp.

template<typename NOTIFICATIONINTERFACE>
typedef ObserverInterface<NotificationInterface> wns::Observer< NOTIFICATIONINTERFACE >::ObserverType

The interface that this Observer implements.

Definition at line 70 of file Observer.hpp.

template<typename NOTIFICATIONINTERFACE>
typedef std::list<SubjectType*> wns::Observer< NOTIFICATIONINTERFACE >::SubjectContainer [private]

Definition at line 208 of file Observer.hpp.

template<typename NOTIFICATIONINTERFACE>
typedef SubjectInterface<ObserverType> wns::Observer< NOTIFICATIONINTERFACE >::SubjectType

The corresponding SubjectInterface that uses the same NotificationInterface.

Reimplemented from wns::ObserverInterface< NOTIFICATIONINTERFACE >.

Definition at line 77 of file Observer.hpp.


Constructor & Destructor Documentation

template<typename NOTIFICATIONINTERFACE>
wns::Observer< NOTIFICATIONINTERFACE >::Observer (  )  [inline]

Definition at line 82 of file Observer.hpp.

template<typename NOTIFICATIONINTERFACE>
wns::Observer< NOTIFICATIONINTERFACE >::Observer ( const Observer< NOTIFICATIONINTERFACE > &  other  )  [inline]

Definition at line 90 of file Observer.hpp.

template<typename NOTIFICATIONINTERFACE>
virtual wns::Observer< NOTIFICATIONINTERFACE >::~Observer (  )  [inline, virtual]

Every Subject that has informed us, that we are attached to it, will receive a detach.

Definition at line 132 of file Observer.hpp.


Member Function Documentation

template<typename NOTIFICATIONINTERFACE>
virtual void wns::Observer< NOTIFICATIONINTERFACE >::addSubject ( SubjectType subject  )  [inline, private, virtual]

Add a subject we are attached to.

Parameters:
subject A subject we are attached to.
Precondition:
The ObserverInterface instance must be attached to subject.
Postcondition:
The ObserverInterface instance will detach itself from subject on destruction.
.

All subjects that register themselves via this function will receive a detach when this Observer instance is destroyed.

Implements wns::ObserverInterface< NOTIFICATIONINTERFACE >.

Definition at line 168 of file Observer.hpp.

template<typename NOTIFICATIONINTERFACE>
template<typename FUNCTOR>
FUNCTOR wns::Observer< NOTIFICATIONINTERFACE >::forEachSubject ( const FUNCTOR &  functor  )  [inline, private]

Parameters:
functor The function to perform on each subject.
Returns:
The functor object passed as functor in the state after it has been applied to all subjects.

Definition at line 201 of file Observer.hpp.

template<typename NOTIFICATIONINTERFACE>
Observer& wns::Observer< NOTIFICATIONINTERFACE >::operator= ( const Observer< NOTIFICATIONINTERFACE > &  other  )  [inline]

Definition at line 105 of file Observer.hpp.

template<typename NOTIFICATIONINTERFACE>
virtual void wns::Observer< NOTIFICATIONINTERFACE >::removeSubject ( SubjectType subject  )  [inline, private, virtual]

Remove a subject we were attached to.

Parameters:
subject The subject to remove.
Precondition:
subject must have been previously added with addSubject().
Postcondition:
The ObserverInterface install won't access subject in any way after the call is finished.
.

Implements wns::ObserverInterface< NOTIFICATIONINTERFACE >.

Definition at line 181 of file Observer.hpp.

template<typename NOTIFICATIONINTERFACE>
void wns::Observer< NOTIFICATIONINTERFACE >::startObserving ( SubjectType subject  )  [inline]

Definition at line 144 of file Observer.hpp.

template<typename NOTIFICATIONINTERFACE>
void wns::Observer< NOTIFICATIONINTERFACE >::stopObserving ( SubjectType subject  )  [inline]

Definition at line 154 of file Observer.hpp.


Member Data Documentation

template<typename NOTIFICATIONINTERFACE>
SubjectContainer wns::Observer< NOTIFICATIONINTERFACE >::subjects [private]

Collection of registered subjects.

Definition at line 215 of file Observer.hpp.


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

Generated on Wed Feb 8 03:32:54 2012 for openWNS by  doxygen 1.5.5