v2.0.0
Loading...
Searching...
No Matches
UTILSLIB::Subject Class Reference

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

#include <observerpattern.h>

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 93 of file observerpattern.h.

Inheritance diagram for UTILSLIB::Subject:
Inheritance graph

Member Typedef Documentation

◆ ConstSPtr

typedef QSharedPointer<const Subject> UTILSLIB::Subject::ConstSPtr

Const shared pointer type for Subject.

Definition at line 97 of file observerpattern.h.

◆ SPtr

typedef QSharedPointer<Subject> UTILSLIB::Subject::SPtr

Shared pointer type for Subject.

Definition at line 96 of file observerpattern.h.

◆ t_Observers

Defines a new IObserver set type.

Definition at line 99 of file observerpattern.h.

Constructor & Destructor Documentation

◆ ~Subject()

Subject::~Subject ( )
virtual

Destroys the Subject.

Definition at line 34 of file observerpattern.cpp.

◆ Subject()

UTILSLIB::Subject::Subject ( )
inlineprotected

Constructs a Subject.

Definition at line 166 of file observerpattern.h.

Member Function Documentation

◆ attach()

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 40 of file observerpattern.cpp.

◆ detach()

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 47 of file observerpattern.cpp.

◆ notify()

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 55 of file observerpattern.cpp.

◆ observerNumDebug()

int UTILSLIB::Subject::observerNumDebug ( )
inline

Returns attached observers.

Returns
attached observers. Returns number of attached observers.
the number of attached observers.

Definition at line 159 of file observerpattern.h.

◆ observers()

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

Returns attached observers.

Returns
attached observers.

Definition at line 177 of file observerpattern.h.

Member Data Documentation

◆ notifyEnabled

bool Subject::notifyEnabled = true
static

Holds the status whether notification is enabled. Used to block notify() and prevent re-entrant notification loops.

Definition at line 135 of file observerpattern.h.


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