User Manual, Developers Guide and API Documentation

wns::Subject< NOTIFICATIONINTERFACE > Class Template Reference
[Misc]

A Subject to an observer. More...

#include <Subject.hpp>

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

Inherited by lte::controlplane::MapHandler, lte::timing::TimingScheduler, lte::timing::TimingScheduler, ofdmaphy::receiver::Receiver, wifimac::convergence::ChannelStateNotification [virtual], wifimac::convergence::NAVNotification [virtual], wifimac::convergence::RxStartEndNotification [virtual], wifimac::convergence::TxStartEndNotification [virtual], wifimac::management::LinkNotificator [virtual], wimac::service::ConnectionManager, wimemac::convergence::ChannelStateNotification [virtual], wimemac::convergence::NAVNotification [virtual], wimemac::convergence::RxStartEndNotification [virtual], wimemac::convergence::TxStartEndNotification [virtual], wns::events::scheduler::Map, wns::Positionable, wns::probe::bus::detail::SubjectPimpl, wns::service::phy::copper::DataTransmissionFeedback [virtual], wns::service::phy::copper::Notification [virtual], and wns::service::phy::copper::Notification [virtual].

Collaboration diagram for wns::Subject< NOTIFICATIONINTERFACE >:

Collaboration graph
[legend]

List of all members.

Public Types

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

Public Member Functions

template<typename FUNCTOR>
FUNCTOR forEachObserver (const FUNCTOR &functor)
 Execute functor on each observer.
template<typename FUNCTOR>
FUNCTOR forEachObserverNoDetachAllowed (const FUNCTOR &functor)
 Execute functor on each of the originals observers.
bool hasObservers () const
Subjectoperator= (const Subject &other)
 Remove own observers, connect to others obsevers.
template<typename NOTIFICATIONFUNCTIONPTR, typename ARG>
void sendNotifies (const NOTIFICATIONFUNCTIONPTR notificationFunctionPtr, const ARG &arg)
 Notify all observers via notificattionFunctionPtr and one argument.
template<typename NOTIFICATIONFUNCTIONPTR>
void sendNotifies (const NOTIFICATIONFUNCTIONPTR notificationFunctionPtr)
 Notify all observers via notificattionFunctionPtr.
 Subject (const Subject &other)
 copy constructor
 Subject ()
 Default constructor.
virtual ~Subject ()
 Removes itself from every attached Observer.

Protected Types

typedef std::list< ObserverType * > ObserverContainer

Private Member Functions

virtual void addObserver (ObserverType *observer)
virtual void removeObserver (ObserverType *observer)

Private Attributes

bool modificationGuard_
ObserverContainer observers
 The observer collection.


Detailed Description

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

Author:
Marc Schinnenburg <marc@schinnenburg.com>

Swen Kuehnlein

Parameters:
NOTIFICATIONINTERFACE The notification interface of the observers.
This implementation of SubjectInterface manages observer registrations, provides methods to access all observers and informs all observers on its destruction.

Derivers can notify all observers with sendNotifies() and perform operations on all observer with forEachObserver().

Attention:
If your class derives from different instantiations of this template, the compiler will not know which attach() and detach() method to call without explicitly telling him. So you must either require your observers to do this, or provide forwarding functions for each attach() and detach() incarnation.
See also:
Observer, SubjectInterface, ObserverInterface.

Definition at line 68 of file Subject.hpp.


Member Typedef Documentation

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

The NotificationInterface used by Subject.

Definition at line 77 of file Subject.hpp.

template<typename NOTIFICATIONINTERFACE>
typedef std::list<ObserverType*> wns::Subject< NOTIFICATIONINTERFACE >::ObserverContainer [protected]

Definition at line 242 of file Subject.hpp.

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

The corresponding ObserverInterface that uses the same NotificationInterface.

Reimplemented from wns::SubjectInterface< OBSERVERINTERFACE >.

Definition at line 84 of file Subject.hpp.

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

The interface that this Subject implements.

Reimplemented in wns::Positionable.

Definition at line 91 of file Subject.hpp.


Constructor & Destructor Documentation

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

Definition at line 96 of file Subject.hpp.

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

Definition at line 105 of file Subject.hpp.

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

Informs every attached observer that it is no longer attached to this Subject instance via ObserverInterface::removeSubject().

Definition at line 148 of file Subject.hpp.


Member Function Documentation

template<typename NOTIFICATIONINTERFACE>
virtual void wns::Subject< NOTIFICATIONINTERFACE >::addObserver ( ObserverType observer  )  [inline, private, virtual]

Add an observer to a subject.

Parameters:
observer The observer to add.
Precondition:
observer must not have been added before.
Postcondition:
observer is attached an will receive notifications according to NotificationInterface and OBSERVERINTERFACE.

All attached observers will be addressed by sendNotifies() and forEachObserver(), and they will be informed of the destruction of this Subject instance via ObserverInterface::removeSubject().

Definition at line 253 of file Subject.hpp.

template<typename NOTIFICATIONINTERFACE>
template<typename FUNCTOR>
FUNCTOR wns::Subject< NOTIFICATIONINTERFACE >::forEachObserver ( const FUNCTOR &  functor  )  [inline]

Parameters:
functor The function to perform an each observer.
Returns:
The functor object passed as functor in the state after it has been applied to all observers.

Definition at line 202 of file Subject.hpp.

template<typename NOTIFICATIONINTERFACE>
template<typename FUNCTOR>
FUNCTOR wns::Subject< NOTIFICATIONINTERFACE >::forEachObserverNoDetachAllowed ( const FUNCTOR &  functor  )  [inline]

Parameters:
functor The function to perform an each observer.
Returns:
The functor object passed as functor in the state after it has been applied to all observers.
Note:
This version operates on the original list of observers. It therefore ensures via guards that the list is not changed during the process.

Definition at line 224 of file Subject.hpp.

template<typename NOTIFICATIONINTERFACE>
bool wns::Subject< NOTIFICATIONINTERFACE >::hasObservers (  )  const [inline]

Definition at line 235 of file Subject.hpp.

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

Definition at line 120 of file Subject.hpp.

template<typename NOTIFICATIONINTERFACE>
virtual void wns::Subject< NOTIFICATIONINTERFACE >::removeObserver ( ObserverType observer  )  [inline, private, virtual]

Remove an observer from a subject.

Parameters:
observer The observer to remove.
Precondition:
observer must have been added before.
Postcondition:
observer is not attached an will not receive any notifications.

Definition at line 270 of file Subject.hpp.

template<typename NOTIFICATIONINTERFACE>
template<typename NOTIFICATIONFUNCTIONPTR, typename ARG>
void wns::Subject< NOTIFICATIONINTERFACE >::sendNotifies ( const NOTIFICATIONFUNCTIONPTR  notificationFunctionPtr,
const ARG &  arg 
) [inline]

Parameters:
notificationFunctionPtr A pointer to a member function of NotificationInterface that receives one argument.
arg The argument to pass to each observer via the call of the member function referenced by notificationFunctionPtr.
Calls the one-argument member function referenced by notificationFunctionPtr on each observer with arg.

Definition at line 187 of file Subject.hpp.

template<typename NOTIFICATIONINTERFACE>
template<typename NOTIFICATIONFUNCTIONPTR>
void wns::Subject< NOTIFICATIONINTERFACE >::sendNotifies ( const NOTIFICATIONFUNCTIONPTR  notificationFunctionPtr  )  [inline]

Parameters:
notificationFunctionPtr A pointer to a member function of NotificationInterface that receives no arguments.
Calls the no-argument member function referenced by notificationFunctionPtr on each observer.

Definition at line 168 of file Subject.hpp.


Member Data Documentation

template<typename NOTIFICATIONINTERFACE>
bool wns::Subject< NOTIFICATIONINTERFACE >::modificationGuard_ [private]

Definition at line 291 of file Subject.hpp.

template<typename NOTIFICATIONINTERFACE>
ObserverContainer wns::Subject< NOTIFICATIONINTERFACE >::observers [private]

The observer collection.

Definition at line 290 of file Subject.hpp.


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

Generated on Sat May 26 03:32:51 2012 for openWNS by  doxygen 1.5.5