Arcane  4.1.12.0
User documentation
Loading...
Searching...
No Matches
Arcane::IObservable Class Referenceabstract

Interface of an observable. More...

#include <arccore/base/IObservable.h>

Public Member Functions

virtual ~IObservable ()
 Frees resources.
virtual void attachObserver (IObserver *obs)=0
 Attaches the observer obs to this observable.
virtual void detachObserver (IObserver *obs)=0
 Detaches the observer obs from this observable.
virtual void notifyAllObservers ()=0
 Notifies all observers.
virtual bool hasObservers () const =0
 True if observers are attached to this observable.
virtual void detachAllObservers ()=0
 Detaches all observers associated with this instance.

Static Public Member Functions

static IObservablecreateDefault ()

Detailed Description

Interface of an observable.

An observable is an object that maintains a list of observers (IObserver) and allows them to be notified of an event via the notifyAllObserver() method.

An observer is added to the list of observers by the attachObserver() method and removed from this same list by detachObserver().

The list of attached observers is ordered, and notifications occur in the order of the list elements. If the same observer is present multiple times, it will be notified as many times as it is present.

Warning
It is essential to remove the observers associated with an observable by calling detachAllObservers() before destroying it.
See also
IObserver

Definition at line 47 of file arccore/src/base/arccore/base/IObservable.h.

Constructor & Destructor Documentation

◆ ~IObservable()

virtual Arcane::IObservable::~IObservable ( )
inlinevirtual

Frees resources.

Definition at line 51 of file arccore/src/base/arccore/base/IObservable.h.

Member Function Documentation

◆ attachObserver()

virtual void Arcane::IObservable::attachObserver ( IObserver * obs)
pure virtual

Attaches the observer obs to this observable.

It is possible to attach an observer more than once.

Implemented in Arcane::Observable.

Referenced by Arcane::ObserverPool::addObserver(), and Arcane::ObserverPool::addObserver().

◆ createDefault()

IObservable * Arcane::IObservable::createDefault ( )
static

Definition at line 109 of file Observable.cc.

◆ detachAllObservers()

virtual void Arcane::IObservable::detachAllObservers ( )
pure virtual

Detaches all observers associated with this instance.

Implemented in Arcane::Observable.

Referenced by Arcane::ObservablePool< KeyType >::~ObservablePool().

◆ detachObserver()

virtual void Arcane::IObservable::detachObserver ( IObserver * obs)
pure virtual

Detaches the observer obs from this observable.

If the observer obs is not present, nothing happens. If it is present multiple times, the last occurrence is deleted.

Implemented in Arcane::Observable.

◆ hasObservers()

virtual bool Arcane::IObservable::hasObservers ( ) const
pure virtual

True if observers are attached to this observable.

Implemented in Arcane::Observable.

◆ notifyAllObservers()

virtual void Arcane::IObservable::notifyAllObservers ( )
pure virtual

Notifies all observers.

For each attached observer, calls IObserver::observerUpdate().

Implemented in Arcane::Observable.

Referenced by Arcane::Variable::notifyBeginWrite(), Arcane::Variable::notifyEndRead(), and Arcane::Variable::syncReferences().


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