/src/quantlib/ql/experimental/commodities/commoditycashflow.hpp
Line | Count | Source (jump to first uncovered line) |
1 | | /* -*- mode: c++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ |
2 | | |
3 | | /* |
4 | | Copyright (C) 2008 J. Erik Radmall |
5 | | |
6 | | This file is part of QuantLib, a free-software/open-source library |
7 | | for financial quantitative analysts and developers - http://quantlib.org/ |
8 | | |
9 | | QuantLib is free software: you can redistribute it and/or modify it |
10 | | under the terms of the QuantLib license. You should have received a |
11 | | copy of the license along with this program; if not, please email |
12 | | <quantlib-dev@lists.sf.net>. The license is also available online at |
13 | | <http://quantlib.org/license.shtml>. |
14 | | |
15 | | This program is distributed in the hope that it will be useful, but WITHOUT |
16 | | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS |
17 | | FOR A PARTICULAR PURPOSE. See the license for more details. |
18 | | */ |
19 | | |
20 | | /*! \file commoditycashflow.hpp |
21 | | \brief Commodity cash flow |
22 | | */ |
23 | | |
24 | | #ifndef quantlib_commodity_cash_flow_hpp |
25 | | #define quantlib_commodity_cash_flow_hpp |
26 | | |
27 | | #include <ql/cashflow.hpp> |
28 | | #include <ql/money.hpp> |
29 | | #include <map> |
30 | | #include <utility> |
31 | | |
32 | | namespace QuantLib { |
33 | | |
34 | | class CommodityCashFlow : public CashFlow { |
35 | | public: |
36 | | CommodityCashFlow(const Date& date, |
37 | | Money discountedAmount, |
38 | | Money undiscountedAmount, |
39 | | Money discountedPaymentAmount, |
40 | | Money undiscountedPaymentAmount, |
41 | | Real discountFactor, |
42 | | Real paymentDiscountFactor, |
43 | | bool finalized) |
44 | 0 | : date_(date), discountedAmount_(std::move(discountedAmount)), |
45 | 0 | undiscountedAmount_(std::move(undiscountedAmount)), |
46 | 0 | discountedPaymentAmount_(std::move(discountedPaymentAmount)), |
47 | 0 | undiscountedPaymentAmount_(std::move(undiscountedPaymentAmount)), |
48 | 0 | discountFactor_(discountFactor), paymentDiscountFactor_(paymentDiscountFactor), |
49 | 0 | finalized_(finalized) {} |
50 | | //! \name Event interface |
51 | | //@{ |
52 | 0 | Date date() const override { return date_; } |
53 | | //@} |
54 | | //! \name CashFlow interface |
55 | | //@{ |
56 | 0 | Real amount() const override { return discountedAmount_.value(); } |
57 | | //@} |
58 | 0 | const Currency& currency() const { |
59 | 0 | return discountedAmount_.currency(); |
60 | 0 | } |
61 | | |
62 | 0 | const Money& discountedAmount() const { return discountedAmount_; } |
63 | 0 | const Money& undiscountedAmount() const { return undiscountedAmount_; } |
64 | 0 | const Money& discountedPaymentAmount() const { |
65 | 0 | return discountedPaymentAmount_; |
66 | 0 | } |
67 | 0 | const Money& undiscountedPaymentAmount() const { |
68 | 0 | return undiscountedPaymentAmount_; |
69 | 0 | } |
70 | 0 | Real discountFactor() const { return discountFactor_; } |
71 | 0 | Real paymentDiscountFactor() const { return paymentDiscountFactor_; } |
72 | 0 | bool finalized() const { return finalized_; } |
73 | | |
74 | | //! \name Visitability |
75 | | //@{ |
76 | | void accept(AcyclicVisitor&) override; |
77 | | //@} |
78 | | private: |
79 | | Date date_; |
80 | | Money discountedAmount_, undiscountedAmount_, |
81 | | discountedPaymentAmount_, undiscountedPaymentAmount_; |
82 | | Real discountFactor_, paymentDiscountFactor_; |
83 | | bool finalized_; |
84 | | }; |
85 | | |
86 | | typedef std::map<Date, ext::shared_ptr<CommodityCashFlow> > |
87 | | CommodityCashFlows; |
88 | | |
89 | | #ifndef __DOXYGEN__ |
90 | | std::ostream& operator<<(std::ostream& out, |
91 | | const CommodityCashFlows& cashFlows); |
92 | | #endif |
93 | | |
94 | | } |
95 | | |
96 | | #endif |