1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
<meta name="robots" content="none">
<title>QuantLib: LazyObject Class Reference</title>
<link rel="stylesheet" href="quantlib.css" type="text/css">
<link rel="stylesheet" href="print.css" type="text/css" media="print">
<link rel="shortcut icon" href="favicon.ico" type="image/x-icon">
<link rel="icon" href="favicon.ico" type="image/x-icon">
</head>
<body>
<div id="container">
<div id="header">
<img class="titleimage"
src="QL-title.jpg" width="212" height="47" border="0"
alt="QuantLib">
<br>
<h3 class="subtitle">A free/open-source library for quantitative finance</h3>
</div>
<div id="menu">
<h3 class="navbartitle">Version 0.9.0</h3>
<hr>
<h3 class="navbartitle">Getting started</h3>
<ul class="navbarlist">
<li class="navlink"><a href="index.html">Introduction</a></li>
<li class="navlink"><a href="overview.html">Project overview</a></li>
<li class="navlink"><a href="where.html">Where to get QuantLib</a></li>
<li class="navlink"><a href="install.html">Installation</a></li>
<li class="navlink"><a href="config.html">Configuration</a></li>
<li class="navlink"><a href="usage.html">Usage</a></li>
<li class="navlink"><a href="history.html">Version history</a></li>
<li class="navlink"><a href="resources.html">Additional resources</a></li>
<li class="navlink"><a href="group.html">The QuantLib group</a></li>
<li class="navlink"><a href="license.html">Copyright and license</a></li>
</ul>
<hr>
<h3 class="navbartitle">Reference manual</h3>
<ul class="navbarlist">
<li class="navlink"><a href="modules.html">Modules</a></li>
<li class="navlink"><a href="hierarchy.html">Class Hierarchy</a></li>
<li class="navlink"><a href="annotated.html">Compound List</a></li>
<li class="navlink"><a href="files.html">File List</a></li>
<li class="navlink"><a href="functions.html">Compound Members</a></li>
<li class="navlink"><a href="globals.html">File Members</a></li>
<li class="navlink"><a href="bug.html">Known Bugs</a></li>
<li class="navlink"><a href="caveats.html">Caveats</a></li>
<li class="navlink"><a href="test.html">Test Suite</a></li>
<li class="navlink"><a href="examples.html">Examples</a></li>
</ul>
</div>
<div id="content">
<!--Doxygen-generated content-->
<!-- Generated by Doxygen 1.5.4 -->
<div class="nav">
<a class="el" href="namespace_quant_lib.html">QuantLib</a>::<a class="el" href="class_quant_lib_1_1_lazy_object.html">LazyObject</a></div>
<h1>LazyObject Class Reference<br>
<small>
[<a class="el" href="group__patterns.html">Design patterns</a>]</small>
</h1><!-- doxytag: class="QuantLib::LazyObject" --><!-- doxytag: inherits="QuantLib::Observable,QuantLib::Observer" --><code>#include <ql/patterns/lazyobject.hpp></code>
<p>
<div class="dynheader">
Inheritance diagram for LazyObject:</div>
<div class="dynsection">
<p><center><img src="class_quant_lib_1_1_lazy_object__inherit__graph.png" border="0" usemap="#_lazy_object__inherit__map" alt="Inheritance graph"></center>
<map name="_lazy_object__inherit__map">
<area shape="rect" href="class_quant_lib_1_1_abcd_atm_vol_curve.html" title="Abcd-interpolated at-the-money (no-smile) volatility curve." alt="" coords="357,5,496,32"><area shape="rect" href="class_quant_lib_1_1_cap_floor_term_vol_curve.html" title="Cap/floor at-the-money term-volatility vector." alt="" coords="343,56,511,83"><area shape="rect" href="class_quant_lib_1_1_cap_floor_term_vol_surface.html" title="Cap/floor smile volatility surface." alt="" coords="337,107,516,133"><area shape="rect" href="class_quant_lib_1_1_cms_market.html" title="set of CMS quotes" alt="" coords="379,157,475,184"><area shape="rect" href="class_quant_lib_1_1_eurodollar_futures_implied_std_dev_quote.html" title="quote for the Eurodollar-future implied standard deviation" alt="" coords="292,208,561,235"><area shape="rect" href="class_quant_lib_1_1_fitted_bond_discount_curve.html" title="Discount curve fitted to a set of fixed-coupon bonds." alt="" coords="333,259,520,285"><area shape="rect" href="class_quant_lib_1_1_flat_forward.html" title="Flat interest-rate curve." alt="" coords="377,309,476,336"><area shape="rect" href="class_quant_lib_1_1_forward_swap_quote.html" title="Quote for a forward starting swap." alt="" coords="352,360,501,387"><area shape="rect" href="class_quant_lib_1_1_implied_std_dev_quote.html" title="quote for the implied standard deviation of an underlying" alt="" coords="348,411,505,437"><area shape="rect" href="class_quant_lib_1_1_instrument.html" title="Abstract instrument class." alt="" coords="380,461,473,488"><area shape="rect" href="class_quant_lib_1_1_piecewise_yield_curve.html" title="Piecewise yield term structure." alt="" coords="349,512,504,539"><area shape="rect" href="class_quant_lib_1_1_piecewise_yo_y_inflation_curve.html" title="Piecewise year-on-year inflation term structure." alt="" coords="327,563,527,589"><area shape="rect" href="class_quant_lib_1_1_piecewise_zero_inflation_curve.html" title="Piecewise zero-inflation term structure." alt="" coords="324,613,529,640"><area shape="rect" href="class_quant_lib_1_1_observable.html" title="Object that notifies its changes to a set of observables." alt="" coords="7,284,100,311"><area shape="rect" href="class_quant_lib_1_1_observer.html" title="Object that gets notified when a given observable changes." alt="" coords="13,335,93,361"></map>
<center><font size="2">[<a href="graph_legend.html">legend</a>]</font></center></div>
<p>
<a href="class_quant_lib_1_1_lazy_object-members.html">List of all members.</a><hr><a name="_details"></a><h2>Detailed Description</h2>
Framework for calculation on demand and result caching.
<p>
<table border="0" cellpadding="0" cellspacing="0">
<tr><td></td></tr>
<tr><td colspan="2"><br><h2>Calculations</h2></td></tr>
<tr><td colspan="2">These methods do not modify the structure of the object and are therefore declared as <code>const</code>. Data members which will be calculated on demand need to be declared as mutable. <br><br></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">void </td><td class="memItemRight" valign="bottom"><a class="el" href="class_quant_lib_1_1_lazy_object.html#467a786be42a2165aa15a26709674547">recalculate</a> ()</td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">void </td><td class="memItemRight" valign="bottom"><a class="el" href="class_quant_lib_1_1_lazy_object.html#bd8698b462ce90fe56b15ce7a0192d3e">freeze</a> ()</td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">void </td><td class="memItemRight" valign="bottom"><a class="el" href="class_quant_lib_1_1_lazy_object.html#26c02da24a82bc72024a8e8d48af0fca">unfreeze</a> ()</td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">virtual void </td><td class="memItemRight" valign="bottom"><a class="el" href="class_quant_lib_1_1_lazy_object.html#10873979f635888606e03f9cb2d8a096">calculate</a> () const </td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">virtual void </td><td class="memItemRight" valign="bottom"><a class="el" href="class_quant_lib_1_1_lazy_object.html#572dbe926524786c64db01e31dba7ab8">performCalculations</a> () const =0</td></tr>
<tr><td colspan="2"><br><h2>Public Member Functions</h2></td></tr>
<tr><td colspan="2"><div class="groupHeader">Observer interface</div></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">void </td><td class="memItemRight" valign="bottom"><a class="el" href="class_quant_lib_1_1_lazy_object.html#c5c54df7ed3b930268c8d7752c101725">update</a> ()</td></tr>
<tr><td colspan="2"><br><h2>Protected Attributes</h2></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top"><a class="anchor" name="bcf8c3b096b3eea8688019abe7180471"></a><!-- doxytag: member="QuantLib::LazyObject::calculated_" ref="bcf8c3b096b3eea8688019abe7180471" args="" -->
bool </td><td class="memItemRight" valign="bottom"><b>calculated_</b></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top"><a class="anchor" name="72e3e9b2ee0ed5ab8aa688b9422d8138"></a><!-- doxytag: member="QuantLib::LazyObject::frozen_" ref="72e3e9b2ee0ed5ab8aa688b9422d8138" args="" -->
bool </td><td class="memItemRight" valign="bottom"><b>frozen_</b></td></tr>
</table>
<hr><h2>Member Function Documentation</h2>
<a class="anchor" name="c5c54df7ed3b930268c8d7752c101725"></a><!-- doxytag: member="QuantLib::LazyObject::update" ref="c5c54df7ed3b930268c8d7752c101725" args="()" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">void update </td>
<td>(</td>
<td class="paramname"> </td>
<td> ) </td>
<td width="100%"><code> [virtual]</code></td>
</tr>
</table>
</div>
<div class="memdoc">
<p>
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.
<p>Implements <a class="el" href="class_quant_lib_1_1_observer.html#99b02345a8a15d3c5ea2844a2253f510">Observer</a>.</p>
<p>Reimplemented in <a class="el" href="class_quant_lib_1_1_abcd_atm_vol_curve.html#c5c54df7ed3b930268c8d7752c101725">AbcdAtmVolCurve</a>, <a class="el" href="class_quant_lib_1_1_forward_swap_quote.html#c5c54df7ed3b930268c8d7752c101725">ForwardSwapQuote</a>, <a class="el" href="class_quant_lib_1_1_piecewise_yo_y_inflation_curve.html#c5c54df7ed3b930268c8d7752c101725">PiecewiseYoYInflationCurve</a>, <a class="el" href="class_quant_lib_1_1_piecewise_zero_inflation_curve.html#c5c54df7ed3b930268c8d7752c101725">PiecewiseZeroInflationCurve</a>, <a class="el" href="class_quant_lib_1_1_cap_floor_term_vol_curve.html#c5c54df7ed3b930268c8d7752c101725">CapFloorTermVolCurve</a>, <a class="el" href="class_quant_lib_1_1_cap_floor_term_vol_surface.html#c5c54df7ed3b930268c8d7752c101725">CapFloorTermVolSurface</a>, <a class="el" href="class_quant_lib_1_1_cms_market.html#c5c54df7ed3b930268c8d7752c101725">CmsMarket</a>, <a class="el" href="class_quant_lib_1_1_fitted_bond_discount_curve.html#c5c54df7ed3b930268c8d7752c101725">FittedBondDiscountCurve</a>, <a class="el" href="class_quant_lib_1_1_flat_forward.html#c5c54df7ed3b930268c8d7752c101725">FlatForward</a>, and <a class="el" href="class_quant_lib_1_1_piecewise_yield_curve.html#c5c54df7ed3b930268c8d7752c101725">PiecewiseYieldCurve</a>.</p>
</div>
</div><p>
<a class="anchor" name="467a786be42a2165aa15a26709674547"></a><!-- doxytag: member="QuantLib::LazyObject::recalculate" ref="467a786be42a2165aa15a26709674547" args="()" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">void recalculate </td>
<td>(</td>
<td class="paramname"> </td>
<td> ) </td>
<td width="100%"></td>
</tr>
</table>
</div>
<div class="memdoc">
<p>
This method force the recalculation of any results which would otherwise be cached. It is not declared as <code>const</code> since it needs to call the non-<code>const</code> <em><b>notifyObservers</b></em> method.<p>
<dl class="note" compact><dt><b>Note:</b></dt><dd>Explicit invocation of this method is <b>not</b> necessary if the object registered itself as observer with the structures on which such results depend. It is strongly advised to follow this policy when possible. </dd></dl>
</div>
</div><p>
<a class="anchor" name="bd8698b462ce90fe56b15ce7a0192d3e"></a><!-- doxytag: member="QuantLib::LazyObject::freeze" ref="bd8698b462ce90fe56b15ce7a0192d3e" args="()" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">void freeze </td>
<td>(</td>
<td class="paramname"> </td>
<td> ) </td>
<td width="100%"></td>
</tr>
</table>
</div>
<div class="memdoc">
<p>
This method constrains the object to return the presently cached results on successive invocations, even if arguments upon which they depend should change.
</div>
</div><p>
<a class="anchor" name="26c02da24a82bc72024a8e8d48af0fca"></a><!-- doxytag: member="QuantLib::LazyObject::unfreeze" ref="26c02da24a82bc72024a8e8d48af0fca" args="()" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">void unfreeze </td>
<td>(</td>
<td class="paramname"> </td>
<td> ) </td>
<td width="100%"></td>
</tr>
</table>
</div>
<div class="memdoc">
<p>
This method reverts the effect of the <em><b>freeze</b></em> method, thus re-enabling recalculations.
</div>
</div><p>
<a class="anchor" name="10873979f635888606e03f9cb2d8a096"></a><!-- doxytag: member="QuantLib::LazyObject::calculate" ref="10873979f635888606e03f9cb2d8a096" args="() const " -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">void calculate </td>
<td>(</td>
<td class="paramname"> </td>
<td> ) </td>
<td width="100%"> const<code> [protected, virtual]</code></td>
</tr>
</table>
</div>
<div class="memdoc">
<p>
This method performs all needed calculations by calling the <em><b>performCalculations</b></em> method.<p>
<dl compact><dt><b><a class="el" href="caveats.html#_caveats000069">Warning:</a></b></dt><dd>Objects cache the results of the previous calculation. Such results will be returned upon later invocations of <em><b>calculate</b></em>. When the results depend on arguments which could change between invocations, the lazy object must register itself as observer of such objects for the calculations to be performed again when they change.</dd></dl>
<dl compact><dt><b><a class="el" href="caveats.html#_caveats000069">Warning:</a></b></dt><dd>Should this method be redefined in derived classes, <a class="el" href="class_quant_lib_1_1_lazy_object.html#10873979f635888606e03f9cb2d8a096">LazyObject::calculate()</a> should be called in the overriding method. </dd></dl>
<p>Reimplemented in <a class="el" href="class_quant_lib_1_1_instrument.html#10873979f635888606e03f9cb2d8a096">Instrument</a>.</p>
</div>
</div><p>
<a class="anchor" name="572dbe926524786c64db01e31dba7ab8"></a><!-- doxytag: member="QuantLib::LazyObject::performCalculations" ref="572dbe926524786c64db01e31dba7ab8" args="() const =0" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">virtual void performCalculations </td>
<td>(</td>
<td class="paramname"> </td>
<td> ) </td>
<td width="100%"> const<code> [protected, pure virtual]</code></td>
</tr>
</table>
</div>
<div class="memdoc">
<p>
This method must implement any calculations which must be (re)done in order to calculate the desired results.
<p>Implemented in <a class="el" href="class_quant_lib_1_1_abcd_atm_vol_curve.html#02b90bbfee3ee29627939544fb59ec93">AbcdAtmVolCurve</a>, <a class="el" href="class_quant_lib_1_1_instrument.html#02b90bbfee3ee29627939544fb59ec93">Instrument</a>, <a class="el" href="class_quant_lib_1_1_convertible_bond.html#02b90bbfee3ee29627939544fb59ec93">ConvertibleBond</a>, <a class="el" href="class_quant_lib_1_1_composite_instrument.html#02b90bbfee3ee29627939544fb59ec93">CompositeInstrument</a>, <a class="el" href="class_quant_lib_1_1_fixed_rate_bond_forward.html#02b90bbfee3ee29627939544fb59ec93">FixedRateBondForward</a>, <a class="el" href="class_quant_lib_1_1_forward.html#02b90bbfee3ee29627939544fb59ec93">Forward</a>, <a class="el" href="class_quant_lib_1_1_stock.html#02b90bbfee3ee29627939544fb59ec93">Stock</a>, <a class="el" href="class_quant_lib_1_1_variance_swap.html#02b90bbfee3ee29627939544fb59ec93">VarianceSwap</a>, <a class="el" href="class_quant_lib_1_1_year_on_year_inflation_swap.html#02b90bbfee3ee29627939544fb59ec93">YearOnYearInflationSwap</a>, <a class="el" href="class_quant_lib_1_1_zero_coupon_inflation_swap.html#02b90bbfee3ee29627939544fb59ec93">ZeroCouponInflationSwap</a>, <a class="el" href="class_quant_lib_1_1_eurodollar_futures_implied_std_dev_quote.html#02b90bbfee3ee29627939544fb59ec93">EurodollarFuturesImpliedStdDevQuote</a>, <a class="el" href="class_quant_lib_1_1_forward_swap_quote.html#02b90bbfee3ee29627939544fb59ec93">ForwardSwapQuote</a>, <a class="el" href="class_quant_lib_1_1_implied_std_dev_quote.html#02b90bbfee3ee29627939544fb59ec93">ImpliedStdDevQuote</a>, <a class="el" href="class_quant_lib_1_1_cap_floor_term_vol_curve.html#02b90bbfee3ee29627939544fb59ec93">CapFloorTermVolCurve</a>, <a class="el" href="class_quant_lib_1_1_cap_floor_term_vol_surface.html#02b90bbfee3ee29627939544fb59ec93">CapFloorTermVolSurface</a>, <a class="el" href="class_quant_lib_1_1_swaption_volatility_matrix.html#02b90bbfee3ee29627939544fb59ec93">SwaptionVolatilityMatrix</a>, and <a class="el" href="class_quant_lib_1_1_flat_forward.html#02b90bbfee3ee29627939544fb59ec93">FlatForward</a>.</p>
</div>
</div><p>
</div>
<div class="footer">
<div class="endmatter">
Documentation generated by
<a href="http://www.doxygen.org">Doxygen</a> 1.5.4
</div>
</div>
</div>
</body>
</html>
|