|
QuantLib: a free/open-source library for quantitative finance
Reference manual - version 1.40
|
Framework for calculation on demand and result caching. More...
#include <ql/patterns/lazyobject.hpp>
Classes | |
| class | Defaults |
| Per-session settings for the LazyObject class. More... | |
Public Member Functions | |
Observer interface | |
| void | update () override |
| bool | isCalculated () const |
| Public Member Functions inherited from Observable | |
| Observable (const Observable &) | |
| Observable & | operator= (const Observable &) |
| Observable (Observable &&)=delete | |
| Observable & | operator= (Observable &&)=delete |
| 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 () |
Notification settings | |
| bool | calculated_ = false |
| bool | frozen_ = false |
| bool | alwaysForward_ |
| void | forwardFirstNotificationOnly () |
| void | alwaysForwardNotifications () |
Calculations | |
These methods do not modify the structure of the object and are therefore declared as const. Data members which will be calculated on demand need to be declared as mutable. | |
| void | recalculate () |
| void | freeze () |
| void | unfreeze () |
| virtual void | calculate () const |
| virtual void | performCalculations () const =0 |
Additional Inherited Members | |
| Public Types inherited from Observer | |
| typedef set_type::iterator | iterator |
Framework for calculation on demand and result caching.
|
overridevirtual |
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 MarkovFunctional, PiecewiseDefaultCurve< Traits, Interpolator, Bootstrap >, PiecewiseDefaultCurve< Traits, Interpolator, Bootstrap >, PiecewiseDefaultCurve< Traits, Interpolator, IterativeBootstrap >, PiecewiseYieldCurve< Traits, Interpolator, Bootstrap >, PiecewiseYieldCurve< detail::SpreadTraits< Traits >, Interpolator, IterativeBootstrap >, PiecewiseYieldCurve< Traits, Interpolator, Bootstrap >, PiecewiseYieldCurve< Traits, Interpolator, IterativeBootstrap >, PiecewiseYieldCurve< traits_type, Interpolator, Bootstrap >, PiecewiseYoYInflationCurve< Interpolator, Bootstrap, Traits >, PiecewiseYoYInflationCurve< Interpolator, Bootstrap, Traits >, PiecewiseYoYInflationCurve< Interpolator, IterativeBootstrap, YoYInflationTraits >, PiecewiseYoYOptionletVolatilityCurve< Interpolator, Bootstrap, Traits >, PiecewiseYoYOptionletVolatilityCurve< Interpolator, Bootstrap, Traits >, PiecewiseYoYOptionletVolatilityCurve< Interpolator, IterativeBootstrap, YoYInflationVolatilityTraits >, PiecewiseZeroInflationCurve< Interpolator, Bootstrap, Traits >, PiecewiseZeroInflationCurve< Interpolator, Bootstrap, Traits >, PiecewiseZeroInflationCurve< Interpolator, IterativeBootstrap, ZeroInflationTraits >, RandomLM< derivedRandomLM, copulaPolicy, USNG >, RandomLM< RandomDefaultLM, copulaPolicy, SobolRsg >, RandomLM< RandomLossLM, copulaPolicy, SobolRsg >, and StrippedOptionletAdapter.
| bool isCalculated | ( | ) | const |
Returns true if the instrument is calculated
| 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.
|
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 AbcdAtmVolCurve, AndreasenHugeVolatilityInterpl, BlackCalibrationHelper, BondForward, CapFloorTermVolCurve, CapFloorTermVolSurface, CappedFlooredCoupon, CashFlow, CompositeInstrument, DigitalCoupon, EnergyBasisSwap, EnergyFuture, EnergyVanillaSwap, EurodollarFuturesImpliedStdDevQuote, FixedRateCoupon, FloatingRateCoupon, Forward, ForwardRateAgreement, ForwardSwapQuote, Gaussian1dModel, Gsr, HestonModelHelper, HestonSLVMCModel, ImpliedStdDevQuote, IndexedCashFlow, InflationCoupon, Instrument, InterpolatedSwaptionVolatilityCube, MarkovFunctional, OptionletStripper1, OptionletStripper2, RandomLM< derivedRandomLM, copulaPolicy, USNG >, RandomLM< RandomDefaultLM, copulaPolicy, SobolRsg >, RandomLM< RandomLossLM, copulaPolicy, SobolRsg >, Stock, StrippedOptionletAdapter, SwaptionVolatilityCube, SwaptionVolatilityMatrix, XabrSwaptionVolatilityCube< Model >, XabrSwaptionVolatilityCube< SwaptionVolCubeNoArbSabrModel >, and XabrSwaptionVolatilityCube< SwaptionVolCubeSabrModel >.
| void forwardFirstNotificationOnly | ( | ) |
This method causes the object 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 notifications until they recalculate, at which point this object would be recalculated too. After recalculation, this object would again forward the first notification received.
Although not always correct, this behavior is a lot faster and thus is the current default. The default can be changed at compile time, or at at run time by calling LazyObject::Defaults::instance().alwaysForwardNotifications(); the run-time change won't affect lazy objects already created.
| void alwaysForwardNotifications | ( | ) |
This method causes the object to forward all notifications received.
Although safer, this behavior is a lot slower and thus usually not the default. The default can be changed at compile time, or at run-time by calling LazyObject::Defaults::instance().alwaysForwardNotifications(); the run-time change won't affect lazy objects already created.