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#include <ql/experimental/commodities/paymentterm.hpp>
21
22namespace QuantLib {
23
24 std::map<std::string, ext::shared_ptr<PaymentTerm::Data> >
25 PaymentTerm::paymentTerms_;
26
27 PaymentTerm::PaymentTerm(const std::string& name,
28 PaymentTerm::EventType eventType,
29 Integer offsetDays,
30 const Calendar& calendar) {
31 std::map<std::string, ext::shared_ptr<PaymentTerm::Data> >::const_iterator i = paymentTerms_.find(x: name);
32 if (i != paymentTerms_.end())
33 data_ = i->second;
34 else {
35 data_ = ext::make_shared<PaymentTerm::Data>(
36 args: name, args&: eventType,
37 args&: offsetDays, args: calendar);
38 paymentTerms_[name] = data_;
39 }
40 }
41
42 std::ostream& operator<<(std::ostream& out, const PaymentTerm& c) {
43 if (!c.empty())
44 return out << c.name();
45 else
46 return out << "null payment term type";
47 }
48
49}
50
51

source code of quantlib/ql/experimental/commodities/paymentterm.cpp