Base class for an observable object that can be tracked by multiple Observer objects. More...
#include <ogdf/basic/Observer.h>
Public Member Functions | |
Observable ()=default | |
Observable (const Observable ©)=delete | |
If you want to copy a subclass of Observable, call the default Observable() constructor. More... | |
Observable (Observable &&move)=delete | |
If you want to move a subclass of Observable, call the default Observable() constructor. More... | |
virtual | ~Observable () |
Observable & | operator= (const Observable ©)=delete |
Observable & | operator= (Observable &&move)=delete |
Protected Member Functions | |
void | clearObservers () |
const ListPure< TObserver * > & | getObservers () const |
Private Member Functions | |
ListPure< TObserver * >::iterator | registerObserver (TObserver *obs) const |
Registers an observer. More... | |
void | unregisterObserver (typename ListPure< TObserver * >::iterator it) const |
Unregisters an observer. More... | |
Private Attributes | |
std::mutex | m_mutexRegArrays |
The critical section for protecting shared access to register/unregister methods. More... | |
ListPure< TObserver * > | m_regObservers |
The registered observers. More... | |
friend | Observer< TObserved, TObserver > |
Base class for an observable object that can be tracked by multiple Observer objects.
Will notify its observers when it 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.
TObserved | The subclass of Observable that will be observed. |
TObserver | The subclass of Observer that defines all virtual callback methods. |
Definition at line 104 of file Observer.h.
|
default |
|
inlinevirtual |
Definition at line 115 of file Observer.h.
|
delete |
If you want to copy a subclass of Observable, call the default Observable() constructor.
Note that Observers can only observe one Observable and in this case will stay with the old one.
|
delete |
If you want to move a subclass of Observable, call the default Observable() constructor.
If you want to also point all Observers to the new location of their Observable, call register for each of them.
|
inlineprotected |
Definition at line 163 of file Observer.h.
|
inlineprotected |
Definition at line 161 of file Observer.h.
|
delete |
|
delete |
|
inlineprivate |
Registers an observer.
obs | is a pointer to the observer that shall be registered |
Definition at line 140 of file Observer.h.
|
inlineprivate |
Unregisters an observer.
it | is an iterator pointing to the entry in the list of registered observers for the observer to be unregistered. |
Definition at line 153 of file Observer.h.
|
mutableprivate |
The critical section for protecting shared access to register/unregister methods.
Definition at line 108 of file Observer.h.
|
mutableprivate |
The registered observers.
Definition at line 110 of file Observer.h.
|
private |
Definition at line 105 of file Observer.h.