Logo
Fully annotated reference manual - version 1.8.12
Loading...
Searching...
No Matches
exceptionquote.hpp
Go to the documentation of this file.
1/*
2 Copyright (C) 2016 Quaternion Risk Management Ltd
3 All rights reserved.
4
5 This file is part of ORE, a free-software/open-source library
6 for transparent pricing and risk analysis - http://opensourcerisk.org
7
8 ORE is free software: you can redistribute it and/or modify it
9 under the terms of the Modified BSD License. You should have received a
10 copy of the license along with this program.
11 The license is also available online at <http://opensourcerisk.org>
12
13 This program is distributed on the basis that it will form a useful
14 contribution to risk analytics and model standardisation, but WITHOUT
15 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
16 FITNESS FOR A PARTICULAR PURPOSE. See the license for more details.
17*/
18
19/*! \file quotes/exceptionquote.hpp
20 \brief throws exception when called
21 \ingroup quotes
22*/
23
24#ifndef quantext_exceptionquote_hpp
25#define quantext_exceptionquote_hpp
26
27#include <ql/quote.hpp>
28
29namespace QuantExt {
30using namespace QuantLib;
31
32//! A dummy quote class that throws an exception when value is called.
33/*!
34 \ingroup quotes
35*/
36class ExceptionQuote : public Quote, public Observer {
37public:
38 ExceptionQuote(std::string exception = "you've hit an 'ExceptionQuote'") : exception_(exception) {}
39 //! \name Inspectors
40 //@{
41 Real quote() const {
42 QL_FAIL(exception_);
43 return 0;
44 }
45 //@}
46 //! \name Quote interface
47 //@{
48 Real value() const override {
49 QL_FAIL(exception_);
50 return 0;
51 }
52 bool isValid() const override {
53 QL_FAIL(exception_);
54 return false;
55 }
56 //@}
57 //! \name Observer interface
58 //@{
59 void update() override { QL_FAIL(exception_); };
60 //@}
61protected:
62 std::string exception_;
63};
64} // namespace QuantExt
65
66#endif
A dummy quote class that throws an exception when value is called.
ExceptionQuote(std::string exception="you've hit an 'ExceptionQuote'")
Real value() const override
bool isValid() const override