QuantLib: a free/open-source library for quantitative finance
fully annotated source code - version 1.34
Loading...
Searching...
No Matches
commoditytype.cpp
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
21#include <ostream>
22
23namespace QuantLib {
24
25 std::map<std::string, ext::shared_ptr<CommodityType::Data> >
27
28 CommodityType::CommodityType(const std::string& name,
29 const std::string& code) {
30 std::map<std::string, ext::shared_ptr<CommodityType::Data> >::const_iterator i = commodityTypes_.find(code);
31 if (i != commodityTypes_.end())
32 data_ = i->second;
33 else {
34 data_ = ext::make_shared<CommodityType::Data>(
35 name, code);
37 }
38 }
39
40 std::ostream& operator<<(std::ostream& out, const CommodityType& c) {
41 if (!c.empty())
42 return out << c.code();
43 else
44 return out << "null commodity type";
45 }
46
47}
48
const std::string & code() const
commodity code, e.g, "HO"
const std::string & name() const
name, e.g, "Heating Oil"
bool empty() const
is this a usable instance?
static std::map< std::string, ext::shared_ptr< Data > > commodityTypes_
CommodityType()=default
default constructor
ext::shared_ptr< Data > data_
commodity type
Definition: any.hpp:35
std::ostream & operator<<(std::ostream &out, GFunctionFactory::YieldCurveModel type)