MNE-CPP  beta 1.0
Public Types | Public Member Functions | Static Public Attributes | Protected Member Functions | List of all members
Subject Class Reference

The Subject class provides the base class of every subject of the observer design pattern. More...

#include <observerpattern.h>

Inheritance diagram for Subject:
RTCOMMANDLIB::CommandParser

Public Types

typedef QSharedPointer< SubjectSPtr
 
typedef QSharedPointer< const SubjectConstSPtr
 
typedef QSet< IObserver * > t_Observers
 

Public Member Functions

virtual ~Subject ()
 
void attach (IObserver *pObserver)
 
void detach (IObserver *pObserver)
 
void notify ()
 
t_Observersobservers ()
 
int observerNumDebug ()
 

Static Public Attributes

static bool notifyEnabled = true
 

Protected Member Functions

 Subject ()
 

Detailed Description

The Subject class provides the base class of every subject of the observer design pattern.

DECLARE BASE CLASS SUBJECT

Definition at line 99 of file observerpattern.h.

Member Typedef Documentation

typedef QSharedPointer<const Subject> Subject::ConstSPtr

Const shared pointer type for Subject.

Definition at line 103 of file observerpattern.h.

typedef QSharedPointer<Subject> Subject::SPtr

Shared pointer type for Subject.

Definition at line 102 of file observerpattern.h.

Defines a new IObserver set type.

Definition at line 105 of file observerpattern.h.

Constructor & Destructor Documentation

Subject::~Subject ( )
virtual

Destroys the Subject.

Definition at line 49 of file observerpattern.cpp.

Subject::Subject ( )
inlineprotected

Constructs a Subject.

Definition at line 165 of file observerpattern.h.

Member Function Documentation

void Subject::attach ( IObserver pObserver)

Attaches an observer to the subject.

Parameters
[in]pObserverpointer to the observer which should be attached to the subject.

Definition at line 57 of file observerpattern.cpp.

void Subject::detach ( IObserver pObserver)

Detaches an observer of the subject.

Parameters
[in]pObserverpointer to the observer which should be detached of the subject.

Definition at line 65 of file observerpattern.cpp.

void Subject::notify ( )

Notifies all attached servers by calling there update method. Is used when subject has updates to provide. This method is enabled when nothifiedEnabled is true.

Definition at line 74 of file observerpattern.cpp.

int Subject::observerNumDebug ( )
inline

Returns number of attached observers. ToDo only for debug purpose -> could be removed

Returns
the number of attached observers.

Definition at line 158 of file observerpattern.h.

Subject::t_Observers & Subject::observers ( )
inline

Returns attached observers.

Returns
attached observers.

Definition at line 177 of file observerpattern.h.

Member Data Documentation

bool Subject::notifyEnabled = true
static

Holds the status whether notification is enabled. This is used to block notify() to make the observer pattern thread safe. It's working like a mutex. The different is that data aren't stored. -> it's okay when values are queued in their own buffer.

Definition at line 141 of file observerpattern.h.


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