Coverage Report

Created: 2025-08-28 06:30

/src/quantlib/ql/experimental/commodities/paymentterm.cpp
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
#include <ql/experimental/commodities/paymentterm.hpp>
21
22
namespace 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
0
                             const Calendar& calendar) {
31
0
        auto i = paymentTerms_.find(name);
32
0
        if (i != paymentTerms_.end())
33
0
            data_ = i->second;
34
0
        else {
35
0
            data_ = ext::make_shared<PaymentTerm::Data>(
36
0
                                 name, eventType,
37
0
                                                       offsetDays, calendar);
38
0
            paymentTerms_[name] = data_;
39
0
        }
40
0
    }
41
42
0
    std::ostream& operator<<(std::ostream& out, const PaymentTerm& c) {
43
0
        if (!c.empty())
44
0
            return out << c.name();
45
0
        else
46
0
            return out << "null payment term type";
47
0
    }
48
49
}
50