LazyObject Class Reference
[Design patterns]
#include <ql/Patterns/lazyobject.hpp>
Inheritance diagram for LazyObject:

Detailed Description
Framework for calculation on demand and result caching.
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 |
Public Member Functions | |
Observer interface | |
void | update () |
Protected Attributes | |
bool | calculated_ |
bool | frozen_ |
Member Function Documentation
|
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 AffineTermStructure, and PiecewiseYieldCurve. |
|
This method force the recalculation of any results which would otherwise be cached. It is not declared as
|
|
This method constrains the object to return the presently cached results on successive invocations, even if arguments upon which they depend should change. |
|
This method reverts the effect of the freeze method, thus re-enabling recalculations. |
|
This method performs all needed calculations by calling the performCalculations method.
Reimplemented in Instrument. |
|
This method must implement any calculations which must be (re)done in order to calculate the desired results. Implemented in Instrument, Bond, Stock, and Swap. |