Framework for calculation on demand and result caching. More...
#include <ql/patterns/lazyobject.hpp>
Inheritance diagram for LazyObject:Public Member Functions | |
Observer interface | |
| void | update () |
Public Member Functions inherited from Observable | |
| Observable (const Observable &) | |
| Observable & | operator= (const Observable &) |
| void | notifyObservers () |
Public Member Functions inherited from Observer | |
| Observer (const Observer &) | |
| Observer & | operator= (const Observer &) |
| std::pair< iterator, bool > | registerWith (const ext::shared_ptr< Observable > &) |
| void | registerWithObservables (const ext::shared_ptr< Observer > &) |
| Size | unregisterWith (const ext::shared_ptr< Observable > &) |
| void | unregisterWithAll () |
| virtual void | deepUpdate () |
Calculations | |
These methods do not modify the structure of the object and are therefore declared as | |
| bool | calculated_ |
| bool | frozen_ |
| bool | alwaysForward_ |
| void | recalculate () |
| void | freeze () |
| void | unfreeze () |
| void | alwaysForwardNotifications () |
| virtual void | calculate () const |
| virtual void | performCalculations () const =0 |
Additional Inherited Members | |
Public Types inherited from Observer | |
| typedef boost::unordered_set< ext::shared_ptr< Observable > > | set_type |
| typedef set_type::iterator | iterator |
Framework for calculation on demand and result caching.
|
virtual |
This method must be implemented in derived classes. An instance of Observer does not call this method directly: instead, it will be called by the observables the instance registered with when they need to notify any changes.
Implements Observer.
Reimplemented in PiecewiseYieldCurve< Traits, Interpolator, Bootstrap >, FlatForward, FittedBondDiscountCurve, CmsMarket, StrippedOptionletAdapter, CapFloorTermVolSurface, CapFloorTermVolCurve, PiecewiseZeroInflationCurve< Interpolator, Bootstrap, Traits >, PiecewiseYoYInflationCurve< Interpolator, Bootstrap, Traits >, PiecewiseDefaultCurve< Traits, Interpolator, Bootstrap >, and ForwardSwapQuote.
| void recalculate | ( | ) |
This method force the recalculation of any results which would otherwise be cached. It is not declared as const since it needs to call the non-const notifyObservers method.
| void freeze | ( | ) |
This method constrains the object to return the presently cached results on successive invocations, even if arguments upon which they depend should change.
| void unfreeze | ( | ) |
This method reverts the effect of the freeze method, thus re-enabling recalculations.
| void alwaysForwardNotifications | ( | ) |
This method causes the object to forward all notifications, even when not calculated. The default behavior is to forward the first notification received, and discard the others until recalculated; the rationale is that observers were already notified, and don't need further notification until they recalculate, at which point this object would be recalculated too. After recalculation, this object would again forward the first notification received.
|
protectedvirtual |
This method performs all needed calculations by calling the performCalculations method.
Reimplemented in Instrument.
|
protectedpure virtual |
This method must implement any calculations which must be (re)done in order to calculate the desired results.
Implemented in SwaptionVolatilityMatrix, SwaptionVolatilityCube, StrippedOptionletAdapter, OptionletStripper2, OptionletStripper1, AndreasenHugeVolatilityInterpl, CapFloorTermVolSurface, CapFloorTermVolCurve, ImpliedStdDevQuote, ForwardSwapQuote, EurodollarFuturesImpliedStdDevQuote, MarkovFunctional, Gsr, Gaussian1dModel, HestonModelHelper, BlackCalibrationHelper, Stock, ForwardRateAgreement, Forward, FixedRateBondForward, CompositeInstrument, Instrument, AbcdAtmVolCurve, HestonSLVMCModel, RiskyBond, RandomLM< derivedRandomLM, copulaPolicy, USNG >, ConvertibleBond, EnergyVanillaSwap, EnergyFuture, and EnergyBasisSwap.