Open
Graph Drawing
Framework

 v. 2023.09 (Elderberry)
 

ogdf::Observer< TObserved, TObserver > Class Template Reference

Base class for an observer for a single Observable object. More...

#include <ogdf/basic/Observer.h>

Public Member Functions

 Observer ()=default
 Constructs instance of Observer class. More...
 
 Observer (const Observer &copy)=delete
 If you want to copy a subclass of Observer, call the default Observer() constructor and optionally also call reregister if it makes sense. More...
 
 Observer (Observer &&move)=delete
 If you want to move a subclass of Observer, call the default Observer() constructor and optionally also call reregister if it makes sense. More...
 
virtual ~Observer ()
 Destroys the instance, unregisters it from watched instance. More...
 
const TObserved * getObserved () const
 
Observeroperator= (const Observer &copy)=delete
 
Observeroperator= (Observer &&move)=delete
 
virtual void registrationChanged (const TObserved *old)
 Called after reregister() changed the observed instance. More...
 
void reregister (const TObserved *obs)
 Associates observer instance with instance obs. More...
 

Private Attributes

ListPure< TObserver * >::iterator m_itObsList
 watched instance More...
 
const TObserved * m_pObserved = nullptr
 

Detailed Description

template<typename TObserved, typename TObserver>
class ogdf::Observer< TObserved, TObserver >

Base class for an observer for a single Observable object.

Will be notified when the observable is destructed and can be subclassed to provide further callbacks. For compatibility with MSVC, the Observer subclass has to be defined before the Observable subclass.

Template Parameters
TObservedThe subclass of Observable that will be observed.
TObserverThe subclass of Observer that defines all virtual callback methods.

Definition at line 53 of file Observer.h.

Constructor & Destructor Documentation

◆ Observer() [1/3]

template<typename TObserved , typename TObserver >
ogdf::Observer< TObserved, TObserver >::Observer ( )
default

Constructs instance of Observer class.

◆ ~Observer()

template<typename TObserved , typename TObserver >
virtual ogdf::Observer< TObserved, TObserver >::~Observer ( )
inlinevirtual

Destroys the instance, unregisters it from watched instance.

Definition at line 59 of file Observer.h.

◆ Observer() [2/3]

template<typename TObserved , typename TObserver >
ogdf::Observer< TObserved, TObserver >::Observer ( const Observer< TObserved, TObserver > &  copy)
delete

If you want to copy a subclass of Observer, call the default Observer() constructor and optionally also call reregister if it makes sense.

◆ Observer() [3/3]

template<typename TObserved , typename TObserver >
ogdf::Observer< TObserved, TObserver >::Observer ( Observer< TObserved, TObserver > &&  move)
delete

If you want to move a subclass of Observer, call the default Observer() constructor and optionally also call reregister if it makes sense.

Member Function Documentation

◆ getObserved()

template<typename TObserved , typename TObserver >
const TObserved* ogdf::Observer< TObserved, TObserver >::getObserved ( ) const
inline

Definition at line 88 of file Observer.h.

◆ operator=() [1/2]

template<typename TObserved , typename TObserver >
Observer& ogdf::Observer< TObserved, TObserver >::operator= ( const Observer< TObserved, TObserver > &  copy)
delete

◆ operator=() [2/2]

template<typename TObserved , typename TObserver >
Observer& ogdf::Observer< TObserved, TObserver >::operator= ( Observer< TObserved, TObserver > &&  move)
delete

◆ registrationChanged()

template<typename TObserved , typename TObserver >
virtual void ogdf::Observer< TObserved, TObserver >::registrationChanged ( const TObserved *  old)
inlinevirtual

Called after reregister() changed the observed instance.

Reimplemented in ogdf::ClusterGraph.

Definition at line 86 of file Observer.h.

◆ reregister()

template<typename TObserved , typename TObserver >
void ogdf::Observer< TObserved, TObserver >::reregister ( const TObserved *  obs)
inline

Associates observer instance with instance obs.

Definition at line 73 of file Observer.h.

Member Data Documentation

◆ m_itObsList

template<typename TObserved , typename TObserver >
ListPure<TObserver*>::iterator ogdf::Observer< TObserved, TObserver >::m_itObsList
private

watched instance

Definition at line 92 of file Observer.h.

◆ m_pObserved

template<typename TObserved , typename TObserver >
const TObserved* ogdf::Observer< TObserved, TObserver >::m_pObserved = nullptr
private

Definition at line 91 of file Observer.h.


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