OpenLexocad  27.1
Base::Subject< _MessageType > Class Template Reference

#include <Observer.h>

Classes

struct  CompareObservers
 
struct  ObserverHolder
 

Public Types

typedef Observer< _MessageType > ObserverType
 
typedef _MessageType MessageType
 
typedef Subject< _MessageType > SubjectType
 

Public Member Functions

 Subject ()
 
virtual ~Subject ()
 
void attach (Observer< _MessageType > *ToObserv)
 
void detach (Observer< _MessageType > *ToObserv)
 
void observerDeleted (Observer< _MessageType > *ToObserv)
 
void detachAll ()
 
void notify_internal (_MessageType &rcReason, size_t deep)
 
void notify (_MessageType &rcReason)
 
Observer< _MessageType > * get (const char *Name)
 
std::vector< Observer< _MessageType > * > getAll ()
 
virtual const char * subject_name (void)
 
void resetObserverTime ()
 
std::map< std::string, double > getObserverTime ()
 

Protected Types

typedef std::set< ObserverHolder, CompareObserversObserverSetType
 

Protected Member Functions

std::vector< ObserverHoldergetObserverSortedByPriority (const ObserverSetType &obs)
 

Protected Attributes

ObserverSetType _ObserverSet
 
ObserverSetType _ObserverSet_AddedLater
 Set of attached observers. More...
 
bool _running_notify
 Set of attached observers at running notify. More...
 
std::list< _MessageType > _messages_WhileRunningNotify
 
std::map< std::string, double > _observerTime
 

Detailed Description

template<class _MessageType>
class Base::Subject< _MessageType >

Subject class Implementation of the well known Observer Design Pattern. The observed object, which inherit FCSubject, will call all its observers in case of changes. A observer class has to Attach itself to the observed object.

See also
FCObserver

Member Typedef Documentation

◆ MessageType

template<class _MessageType>
typedef _MessageType Base::Subject< _MessageType >::MessageType

◆ ObserverSetType

template<class _MessageType>
typedef std::set<ObserverHolder, CompareObservers> Base::Subject< _MessageType >::ObserverSetType
protected

◆ ObserverType

template<class _MessageType>
typedef Observer<_MessageType> Base::Subject< _MessageType >::ObserverType

◆ SubjectType

template<class _MessageType>
typedef Subject<_MessageType> Base::Subject< _MessageType >::SubjectType

Constructor & Destructor Documentation

◆ Subject()

template<class _MessageType>
Base::Subject< _MessageType >::Subject ( )
inline

A constructor. No special function so far.

◆ ~Subject()

template<class _MessageType>
virtual Base::Subject< _MessageType >::~Subject ( )
inlinevirtual

A destructor. No special function so far.

Member Function Documentation

◆ attach()

template<class _MessageType>
void Base::Subject< _MessageType >::attach ( Observer< _MessageType > *  ToObserv)
inline

Attach an Observer Attach an Observer to the list of Observers which get called when Notify is called.

Parameters
ToObservA pointer to a concrete Observer
See also
Notify

◆ detach()

template<class _MessageType>
void Base::Subject< _MessageType >::detach ( Observer< _MessageType > *  ToObserv)
inline

Detach an Observer Detach an Observer from the list of Observers which get called when Notify is called.

Parameters
ToObservA pointer to a concrete Observer
See also
Notify

◆ detachAll()

template<class _MessageType>
void Base::Subject< _MessageType >::detachAll ( )
inline

Clears the list of all registered observers.

Note
Using this function in your code may be an indication of design problems.

◆ get()

template<class _MessageType>
Observer<_MessageType>* Base::Subject< _MessageType >::get ( const char *  Name)
inline

Get an Observer by name Get a observer by name if the observer reimplements the Name() method.

See also
Observer

◆ getAll()

template<class _MessageType>
std::vector<Observer<_MessageType>*> Base::Subject< _MessageType >::getAll ( )
inline

◆ getObserverSortedByPriority()

template<class _MessageType>
std::vector<ObserverHolder> Base::Subject< _MessageType >::getObserverSortedByPriority ( const ObserverSetType obs)
inlineprotected

◆ getObserverTime()

template<class _MessageType>
std::map<std::string, double> Base::Subject< _MessageType >::getObserverTime ( )
inline

◆ notify()

template<class _MessageType>
void Base::Subject< _MessageType >::notify ( _MessageType &  rcReason)
inline

◆ notify_internal()

template<class _MessageType>
void Base::Subject< _MessageType >::notify_internal ( _MessageType &  rcReason,
size_t  deep 
)
inline

Notify all Observers Send a message to all Observers attached to this subject. The Message depends on the implementation of a concrete Observer and Subject.

See also
Notify

◆ observerDeleted()

template<class _MessageType>
void Base::Subject< _MessageType >::observerDeleted ( Observer< _MessageType > *  ToObserv)
inline

◆ resetObserverTime()

template<class _MessageType>
void Base::Subject< _MessageType >::resetObserverTime ( )
inline

◆ subject_name()

template<class _MessageType>
virtual const char* Base::Subject< _MessageType >::subject_name ( void  )
inlinevirtual

Member Data Documentation

◆ _messages_WhileRunningNotify

template<class _MessageType>
std::list<_MessageType> Base::Subject< _MessageType >::_messages_WhileRunningNotify
protected

◆ _ObserverSet

template<class _MessageType>
ObserverSetType Base::Subject< _MessageType >::_ObserverSet
protected

◆ _ObserverSet_AddedLater

template<class _MessageType>
ObserverSetType Base::Subject< _MessageType >::_ObserverSet_AddedLater
protected

Set of attached observers.

◆ _observerTime

template<class _MessageType>
std::map<std::string, double> Base::Subject< _MessageType >::_observerTime
protected

◆ _running_notify

template<class _MessageType>
bool Base::Subject< _MessageType >::_running_notify
protected

Set of attached observers at running notify.


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