QuantLib: a free/open-source library for quantitative finance
Fully annotated sources - version 1.32
Loading...
Searching...
No Matches
simplecashflow.hpp
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
25#ifndef quantlib_simple_cash_flow_hpp
26#define quantlib_simple_cash_flow_hpp
27
28#include <ql/patterns/visitor.hpp>
29#include <ql/cashflow.hpp>
30
31namespace QuantLib {
32
34
35 class SimpleCashFlow : public CashFlow {
36 public:
38 const Date& date);
40
41 Date date() const override { return date_; }
43
45 Real amount() const override { return amount_; }
47
49 void accept(AcyclicVisitor&) override;
51 private:
54 };
55
56
58
61 class Redemption : public SimpleCashFlow {
62 public:
64 const Date& date)
67
68 void accept(AcyclicVisitor&) override;
70 };
71
73
77 public:
79 const Date& date)
82
83 void accept(AcyclicVisitor&) override;
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
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