QuantLib: a free/open-source library for quantitative finance
Fully annotated sources - version 1.32
Loading...
Searching...
No Matches
simplequote.hpp
1/* -*- mode: c++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2
3/*
4 Copyright (C) 2007 Ferdinando Ametrano
5 Copyright (C) 2000, 2001, 2002, 2003 RiskMap srl
6
7 This file is part of QuantLib, a free-software/open-source library
8 for financial quantitative analysts and developers - http://quantlib.org/
9
10 QuantLib is free software: you can redistribute it and/or modify it
11 under the terms of the QuantLib license. You should have received a
12 copy of the license along with this program; if not, please email
13 <quantlib-dev@lists.sf.net>. The license is also available online at
14 <http://quantlib.org/license.shtml>.
15
16 This program is distributed in the hope that it will be useful, but WITHOUT
17 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
18 FOR A PARTICULAR PURPOSE. See the license for more details.
19*/
20
25#ifndef quantlib_simple_quote_hpp
26#define quantlib_simple_quote_hpp
27
28#include <ql/quote.hpp>
29
30namespace QuantLib {
31
33 class SimpleQuote : public Quote {
34 public:
37
38 Real value() const override;
39 bool isValid() const override;
41
43
45 void reset();
47 private:
49 };
50
51 // inline definitions
52
54 : value_(value) {}
55
56 inline Real SimpleQuote::value() const {
57 QL_ENSURE(isValid(), "invalid SimpleQuote");
58 return value_;
59 }
60
61 inline bool SimpleQuote::isValid() const {
62 return value_!=Null<Real>();
63 }
64
66 Real diff = value-value_;
67 if (diff != 0.0) {
68 value_ = value;
70 }
71 return diff;
72 }
73
74 inline void SimpleQuote::reset() {
76 }
77
78}
79
80#endif
template class providing a null value for a given type.
Definition: null.hpp:76
purely virtual base class for market observables
Definition: quote.hpp:37
market element returning a stored value
Definition: simplequote.hpp:33
Real setValue(Real value=Null< Real >())
returns the difference between the new value and the old value
Definition: simplequote.hpp:65
SimpleQuote(Real value=Null< Real >())
Definition: simplequote.hpp:53
Real value() const override
returns the current value
Definition: simplequote.hpp:56
bool isValid() const override
returns true if the Quote holds a valid value
Definition: simplequote.hpp:61
QL_REAL Real
real number
Definition: types.hpp:50
Definition: any.hpp:35