QuantLib: a free/open-source library for quantitative finance
fully annotated source code - version 1.34
Loading...
Searching...
No Matches
paymentterm.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) 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 paymentterm.hpp
21 \brief Payment term
22*/
23
24#ifndef quantlib_payment_term_hpp
25#define quantlib_payment_term_hpp
26
27#include <ql/time/calendar.hpp>
28#include <map>
29#include <utility>
30
31namespace QuantLib {
32
34 public:
36
37 PaymentTerm() = default;
38 PaymentTerm(const std::string& name,
41 const Calendar& calendar);
42 //! \name Inspectors
43 //@{
44 //! name, e.g, "Pricing end + 5 days"
45 const std::string& name() const;
46 EventType eventType() const;
47 Integer offsetDays() const;
48 const Calendar& calendar() const;
49
50 bool empty() const;
51 //@}
52 Date getPaymentDate(const Date& date) const;
53 protected:
54 struct Data;
55 ext::shared_ptr<Data> data_;
56
57 struct Data {
58 std::string name;
62
64 };
65
66 static std::map<std::string, ext::shared_ptr<Data> > paymentTerms_;
67 };
68
69 /*! \relates PaymentTerm */
70 bool operator==(const PaymentTerm&,
71 const PaymentTerm&);
72
73 /*! \relates PaymentTerm */
74 bool operator!=(const PaymentTerm&,
75 const PaymentTerm&);
76
77 /*! \relates PaymentTerm */
78 std::ostream& operator<<(std::ostream&,
79 const PaymentTerm&);
80
81
82 inline PaymentTerm::Data::Data(std::string name,
83 PaymentTerm::EventType eventType,
84 Integer offsetDays,
85 Calendar calendar)
86 : name(std::move(name)), eventType(eventType), offsetDays(offsetDays),
87 calendar(std::move(calendar)) {}
88
89 inline const std::string& PaymentTerm::name() const {
90 return data_->name;
91 }
92
94 return data_->eventType;
95 }
96
98 return data_->offsetDays;
99 }
100
101 inline const Calendar& PaymentTerm::calendar() const {
102 return data_->calendar;
103 }
104
105 inline Date PaymentTerm::getPaymentDate(const Date& date) const {
106 return data_->calendar.adjust(date + data_->offsetDays);
107 }
108
109 inline bool PaymentTerm::empty() const {
110 return !data_;
111 }
112
113 inline bool operator==(const PaymentTerm& c1, const PaymentTerm& c2) {
114 return c1.name() == c2.name();
115 }
116
117 inline bool operator!=(const PaymentTerm& c1, const PaymentTerm& c2) {
118 return !(c1 == c2);
119 }
120
121}
122
123
124#endif
calendar class
calendar class
Definition: calendar.hpp:61
Concrete date class.
Definition: date.hpp:125
Date getPaymentDate(const Date &date) const
const std::string & name() const
name, e.g, "Pricing end + 5 days"
Definition: paymentterm.hpp:89
bool operator!=(const PaymentTerm &, const PaymentTerm &)
Integer offsetDays() const
Definition: paymentterm.hpp:97
const Calendar & calendar() const
static std::map< std::string, ext::shared_ptr< Data > > paymentTerms_
Definition: paymentterm.hpp:66
EventType eventType() const
Definition: paymentterm.hpp:93
bool operator==(const PaymentTerm &, const PaymentTerm &)
ext::shared_ptr< Data > data_
Definition: paymentterm.hpp:55
QL_INTEGER Integer
integer number
Definition: types.hpp:35
Definition: any.hpp:35
bool operator==(const Currency &c1, const Currency &c2)
Definition: currency.hpp:231
std::ostream & operator<<(std::ostream &out, GFunctionFactory::YieldCurveModel type)
bool operator!=(const Currency &c1, const Currency &c2)
Definition: currency.hpp:236
STL namespace.
Data(std::string name, EventType eventType, Integer offsetDays, Calendar calendar)
Definition: paymentterm.hpp:82