QuantLib
A free/open-source library for quantitative finance
Fully annotated sources - version 1.22
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 <ql/patterns/observable.hpp>

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

Public Member Functions

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

Private Types

typedef boost::unordered_set< Observer * >::iterator iterator
 

Private Member Functions

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

Private Attributes

boost::unordered_set< Observer * > observers_
 
ObservableSettingssettings_
 

Friends

class Observer
 

Detailed Description

Object that notifies its changes to a set of observers.

Definition at line 79 of file observable.hpp.

Member Typedef Documentation

◆ iterator

typedef boost::unordered_set<Observer*>::iterator iterator
private

Definition at line 92 of file observable.hpp.

Constructor & Destructor Documentation

◆ Observable() [1/2]

Definition at line 83 of file observable.hpp.

◆ Observable() [2/2]

Observable ( const Observable )

Definition at line 154 of file observable.hpp.

◆ ~Observable()

virtual ~Observable ( )
virtualdefault

Member Function Documentation

◆ operator=()

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 168 of file observable.hpp.

+ Here is the call graph for this function:

◆ 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< boost::unordered_set< Observer * >::iterator, bool > registerObserver ( Observer o)
private

Definition at line 177 of file observable.hpp.

◆ unregisterObserver()

Size unregisterObserver ( Observer o)
private

Definition at line 181 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 80 of file observable.hpp.

Member Data Documentation

◆ observers_

boost::unordered_set<Observer*> observers_
private

Definition at line 95 of file observable.hpp.

◆ settings_

ObservableSettings& settings_
private

Definition at line 96 of file observable.hpp.