QuantLib: a free/open-source library for quantitative finance
fully annotated source code - version 1.34
Loading...
Searching...
No Matches
simplecashflow.hpp
Go to the documentation of this file.
1/* -*- mode: c++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2
3/*
4 Copyright (C) 2000, 2001, 2002, 2003 RiskMap srl
5 Copyright (C) 2010 StatPro Italia 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
21/*! \file simplecashflow.hpp
22 \brief Predetermined cash flow
23*/
24
25#ifndef quantlib_simple_cash_flow_hpp
26#define quantlib_simple_cash_flow_hpp
27
29#include <ql/cashflow.hpp>
30
31namespace QuantLib {
32
33 //! Predetermined cash flow
34 /*! This cash flow pays a predetermined amount at a given date. */
35 class SimpleCashFlow : public CashFlow {
36 public:
38 const Date& date);
39 //! \name Event interface
40 //@{
41 Date date() const override { return date_; }
42 //@}
43 //! \name CashFlow interface
44 //@{
45 Real amount() const override { return amount_; }
46 //@}
47 //! \name Visitability
48 //@{
49 void accept(AcyclicVisitor&) override;
50 //@}
51 private:
54 };
55
56
57 //! Bond redemption
58 /*! This class specializes SimpleCashFlow so that visitors
59 can perform more detailed cash-flow analysis.
60 */
61 class Redemption : public SimpleCashFlow {
62 public:
64 const Date& date)
66 //! \name Visitability
67 //@{
68 void accept(AcyclicVisitor&) override;
69 //@}
70 };
71
72 //! Amortizing payment
73 /*! This class specializes SimpleCashFlow so that visitors
74 can perform more detailed cash-flow analysis.
75 */
77 public:
79 const Date& date)
81 //! \name Visitability
82 //@{
83 void accept(AcyclicVisitor&) override;
84 //@}
85 };
86
87
88 // inline definitions
89
91 auto* v1 = dynamic_cast<Visitor<SimpleCashFlow>*>(&v);
92 if (v1 != nullptr)
93 v1->visit(*this);
94 else
95 CashFlow::accept(v);
96 }
97
99 auto* v1 = dynamic_cast<Visitor<Redemption>*>(&v);
100 if (v1 != nullptr)
101 v1->visit(*this);
102 else
104 }
105
107 auto* v1 = dynamic_cast<Visitor<AmortizingPayment>*>(&v);
108 if (v1 != nullptr)
109 v1->visit(*this);
110 else
112 }
113
114}
115
116#endif
Base class for cash flows.
degenerate base class for the Acyclic Visitor pattern
Definition: visitor.hpp:33
void accept(AcyclicVisitor &) override
AmortizingPayment(Real amount, const Date &date)
Base class for cash flows.
Definition: cashflow.hpp:40
Concrete date class.
Definition: date.hpp:125
Bond redemption.
Redemption(Real amount, const Date &date)
void accept(AcyclicVisitor &) override
Predetermined cash flow.
Real amount() const override
returns the amount of the cash flow
void accept(AcyclicVisitor &) override
Date date() const override
Visitor for a specific class
Definition: visitor.hpp:40
virtual void visit(T &)=0
QL_REAL Real
real number
Definition: types.hpp:50
Definition: any.hpp:35
ext::shared_ptr< BlackVolTermStructure > v
degenerate base class for the Acyclic Visitor pattern