Logo
Fully annotated reference manual - version 1.8.12
Loading...
Searching...
No Matches
indexnametranslator.hpp
Go to the documentation of this file.
1/*
2 Copyright (C) 2022 Quaternion Risk Management Ltd
3 All rights reserved.
4
5 This file is part of ORE, a free-software/open-source library
6 for transparent pricing and risk analysis - http://opensourcerisk.org
7
8 ORE is free software: you can redistribute it and/or modify it
9 under the terms of the Modified BSD License. You should have received a
10 copy of the license along with this program.
11 The license is also available online at <http://opensourcerisk.org>
12
13 This program is distributed on the basis that it will form a useful
14 contribution to risk analytics and model standardisation, but WITHOUT
15 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
16 FITNESS FOR A PARTICULAR PURPOSE. See the license for more details.
17*/
18
19/*! \file ored/utilities/indexnametranslator.hpp
20 \brief translates between QuantLib::Index::name() and ORE names
21 \ingroup utilities
22*/
23
24#pragma once
25
26#include <ql/patterns/singleton.hpp>
27
28#include <boost/bimap.hpp>
29#include <boost/thread/shared_mutex.hpp>
30#include <boost/thread/lock_types.hpp>
31
32#include <string>
33
34namespace ore {
35namespace data {
36
37//! IndexNameTranslator
38/*! Allows translating from QuantLib::Index::name() to the ORE name that parses to that index and vice versa. */
39class IndexNameTranslator : public QuantLib::Singleton<IndexNameTranslator, std::integral_constant<bool, true>> {
40public:
41 //! throws if qlName is not known
42 std::string oreName(const std::string& qlName) const;
43
44 //! throws if oreName is not known
45 std::string qlName(const std::string& oreName) const;
46
47 //! adds a pair to the mapping
48 void add(const std::string& qlName, const std::string& oreName);
49
50 //! clears the mapping
51 void clear();
52
53private:
54 boost::bimap<std::string, std::string> data_;
55 mutable boost::shared_mutex mutex_;
56};
57
58} // namespace data
59} // namespace ore
boost::bimap< std::string, std::string > data_
std::string oreName(const std::string &qlName) const
throws if qlName is not known
void add(const std::string &qlName, const std::string &oreName)
adds a pair to the mapping
void clear()
clears the mapping
std::string qlName(const std::string &oreName) const
throws if oreName is not known
@ data
Definition: log.hpp:77
Serializable Credit Default Swap.
Definition: namespaces.docs:23