Logo
Fully annotated reference manual - version 1.8.12
Loading...
Searching...
No Matches
indexnametranslator.cpp
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
21
22#include <ql/errors.hpp>
23
24namespace ore {
25namespace data {
26
27std::string IndexNameTranslator::oreName(const std::string& qlName) const {
28 boost::shared_lock<boost::shared_mutex> lock(mutex_);
29 auto n = data_.left.find(qlName);
30 if (n == data_.left.end())
31 return qlName;
32 else
33 return n->second;
34}
35
36std::string IndexNameTranslator::qlName(const std::string& oreName) const {
37 boost::shared_lock<boost::shared_mutex> lock(mutex_);
38 auto n = data_.right.find(oreName);
39 QL_REQUIRE(n != data_.right.end(), "IndexNameTranslator: oreName '" << oreName << "' not found.");
40 return n->second;
41}
42
43void IndexNameTranslator::add(const std::string& qlName, const std::string& oreName) {
44 boost::unique_lock<boost::shared_mutex> lock(mutex_);
45 data_.insert(boost::bimap<std::string, std::string>::value_type(qlName, oreName));
46 TLOG("IndexNameTranslator: adding '" << qlName << "' <-> '" << oreName << "'");
47}
48
50 boost::unique_lock<boost::shared_mutex> lock(mutex_);
51 data_.clear();
52}
53
54} // namespace data
55} // 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
translates between QuantLib::Index::name() and ORE names
Classes and functions for log message handling.
@ data
Definition: log.hpp:77
#define TLOG(text)
Logging Macro (Level = Data)
Definition: log.hpp:556
Serializable Credit Default Swap.
Definition: namespaces.docs:23