FreeCAD C++
Public Member Functions | Protected Attributes | List of all members
Base::Subject< _MessageType > Class Template Reference

#include <Base/Observer.h>

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

Public Member Functions

 Subject ()
 
virtual ~Subject ()
 
void Attach (Observer< _MessageType > *ToObserv)
 
void Detach (Observer< _MessageType > *ToObserv)
 
void Notify (_MessageType rcReason)
 
Observer< _MessageType > * Get (const char *Name)
 
void ClearObserver ()
 

Protected Attributes

std::set< Observer< _MessageType > * > _ObserverSet
 Vector of attached observers.
 

Constructor & Destructor Documentation

◆ Subject()

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

A constructor. No special function so far.

◆ ~Subject()

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

A destructor. No special function so far.

Member Function Documentation

◆ Attach()

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

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

◆ ClearObserver()

template<class _MessageType>
void Base::Subject< _MessageType >::ClearObserver ( )

Clears the list of all registered observers.

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

◆ Detach()

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

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

◆ Get()

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

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

See also
Observer

◆ Notify()

template<class _MessageType>
void Base::Subject< _MessageType >::Notify ( _MessageType  rcReason)

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

See also
Notify