QuantLib: a free/open-source library for quantitative finance
fully annotated source code - version 1.34
Loading...
Searching...
No Matches
Public Member Functions | Private Types | Private Member Functions | Private Attributes | Friends | List of all members
Observable Class Reference

Object that notifies its changes to a set of observers. More...

#include <observable.hpp>

+ Inheritance diagram for Observable:
+ Collaboration diagram for Observable:

Public Member Functions

 Observable ()
 
 Observable (const Observable &)
 
Observableoperator= (const Observable &)
 
 Observable (Observable &&)=delete
 
Observableoperator= (Observable &&)=delete
 
virtual ~Observable ()=default
 
void notifyObservers ()
 

Private Types

typedef std::set< Observer * > set_type
 
typedef set_type::iterator iterator
 

Private Member Functions

std::pair< iterator, boolregisterObserver (Observer *)
 
Size unregisterObserver (Observer *)
 

Private Attributes

set_type observers_
 

Friends

class Observer
 
class ObservableSettings
 

Detailed Description

Object that notifies its changes to a set of observers.

Definition at line 62 of file observable.hpp.

Member Typedef Documentation

◆ set_type

typedef std::set<Observer*> set_type
private

Definition at line 79 of file observable.hpp.

◆ iterator

typedef set_type::iterator iterator
private

Definition at line 80 of file observable.hpp.

Constructor & Destructor Documentation

◆ Observable() [1/3]

Observable ( )
default

◆ Observable() [2/3]

Observable ( const Observable )

Definition at line 173 of file observable.hpp.

◆ Observable() [3/3]

Observable ( Observable &&  )
delete

◆ ~Observable()

virtual ~Observable ( )
virtualdefault

Member Function Documentation

◆ operator=() [1/2]

Observable & operator= ( const Observable o)
Warning:
notification is sent before the copy constructor has a chance of actually change the data members. Therefore, observers whose update() method tries to use their observables will not see the updated values. It is suggested that the update() method just raise a flag in order to trigger a later recalculation.

Definition at line 186 of file observable.hpp.

+ Here is the call graph for this function:

◆ operator=() [2/2]

Observable & operator= ( Observable &&  )
delete

◆ notifyObservers()

void notifyObservers ( )

This method should be called at the end of non-const methods or when the programmer desires to notify any changes.

Definition at line 56 of file observable.cpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ registerObserver()

std::pair< Observable::iterator, bool > registerObserver ( Observer o)
private

Definition at line 195 of file observable.hpp.

◆ unregisterObserver()

Size unregisterObserver ( Observer o)
private

Definition at line 199 of file observable.hpp.

+ Here is the call graph for this function:

Friends And Related Function Documentation

◆ Observer

friend class Observer
friend

Definition at line 63 of file observable.hpp.

◆ ObservableSettings

friend class ObservableSettings
friend

Definition at line 64 of file observable.hpp.

Member Data Documentation

◆ observers_

set_type observers_
private

Definition at line 83 of file observable.hpp.