DART  6.7.3
dart::common::Observer Class Reference

The Observer class should be inherited by any class that wants to respond in a customized way to the destruction of a Subject. More...

#include <Observer.hpp>

Inheritance diagram for dart::common::Observer:
dart::common::sub_ptr< dart::dynamics::InverseKinematics > dart::common::sub_ptr< dart::dynamics::JacobianNode > dart::common::sub_ptr< dart::gui::osg::InteractiveTool > dart::collision::CollisionGroup::ShapeFrameObserver dart::common::sub_ptr< T > dart::gui::osg::DefaultEventHandler dart::gui::osg::DragAndDrop dart::gui::osg::MouseEventHandler

Public Member Functions

virtual ~Observer ()
 Destructor will notify all Subjects that it is destructing. More...
 

Protected Member Functions

void receiveDestructionNotification (const Subject *_subject)
 Called whenever a Subject is destroyed (or sends out a destruction notification). More...
 
virtual void handleDestructionNotification (const Subject *_subject)
 Called by receiveDestructionNotification(). More...
 
void addSubject (const Subject *_subject)
 Add a Subject for this Observer. More...
 
void removeSubject (const Subject *_subject)
 Remove a Subject from this Observer. More...
 
void removeAllSubjects ()
 Remove all Subjects from this Observer. More...
 

Protected Attributes

std::set< const Subject * > mSubjects
 List of current Subjects for this Observer. More...
 

Friends

class Subject
 

Detailed Description

The Observer class should be inherited by any class that wants to respond in a customized way to the destruction of a Subject.

Simply override the Observer::handleDestructionNotification() function to customize how your class responds to the destruction of a Subject.

dart::sub_ptr is a templated smart pointer that will change itself into a nullptr when its Subject is destroyed. It offers one of the easiest ways to take advantage of the Subject/Observer pattern.

Constructor & Destructor Documentation

◆ ~Observer()

dart::common::Observer::~Observer ( )
virtual

Destructor will notify all Subjects that it is destructing.

Member Function Documentation

◆ addSubject()

void dart::common::Observer::addSubject ( const Subject _subject)
protected

Add a Subject for this Observer.

◆ handleDestructionNotification()

◆ receiveDestructionNotification()

void dart::common::Observer::receiveDestructionNotification ( const Subject _subject)
protected

Called whenever a Subject is destroyed (or sends out a destruction notification).

Override handleDestructionNotification() in order to customize your class's response to destruction notifications.

◆ removeAllSubjects()

void dart::common::Observer::removeAllSubjects ( )
protected

Remove all Subjects from this Observer.

◆ removeSubject()

void dart::common::Observer::removeSubject ( const Subject _subject)
protected

Remove a Subject from this Observer.

Friends And Related Function Documentation

◆ Subject

friend class Subject
friend

Member Data Documentation

◆ mSubjects

std::set<const Subject*> dart::common::Observer::mSubjects
protected

List of current Subjects for this Observer.