Skip to content

Commit cbd7c1b

Browse files
pcaspersjenkins
authored andcommitted
QPR-11524 fix
1 parent c6f5541 commit cbd7c1b

2 files changed

Lines changed: 17 additions & 20 deletions

File tree

OREData/ored/configuration/conventions.cpp

Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2444,6 +2444,7 @@ void Conventions::fromXML(XMLNode* node) {
24442444
if (convention) {
24452445
try {
24462446
id = XMLUtils::getChildValue(child, "Id", true);
2447+
DLOG("Building Convention " << id);
24472448
convention->fromXML(child);
24482449
add(convention);
24492450
} catch (const std::exception& e) {
@@ -2453,6 +2454,7 @@ void Conventions::fromXML(XMLNode* node) {
24532454
} else {
24542455
try {
24552456
id = XMLUtils::getChildValue(child, "Id", true);
2457+
DLOG("Reading Convention " << id);
24562458
unparsed_[id] = std::make_pair(type, XMLUtils::toString(child));
24572459
} catch (const std::exception& e) {
24582460
WLOG("Exception during retrieval of convention "
@@ -2474,7 +2476,7 @@ XMLNode* Conventions::toXML(XMLDocument& doc) {
24742476
return conventionsNode;
24752477
}
24762478

2477-
void Conventions::clear() {
2479+
void Conventions::clear() const {
24782480
boost::unique_lock<boost::shared_mutex> lock(mutex_);
24792481
data_.clear();
24802482
}
@@ -2511,15 +2513,16 @@ boost::shared_ptr<Convention> Conventions::get(const string& id) const {
25112513
return it->second;
25122514
}
25132515

2514-
boost::unique_lock<boost::shared_mutex> lock(mutex_);
2515-
25162516
std::string type, unparsed;
2517-
if (auto it = unparsed_.find(id); it != unparsed_.end()) {
2518-
std::tie(type, unparsed) = it->second;
2519-
unparsed_.erase(id);
2520-
} else if (auto it = unparsed_.find(flip(id)); it != unparsed_.end()) {
2521-
std::tie(type, unparsed) = it->second;
2522-
unparsed_.erase(flip(id));
2517+
{
2518+
boost::unique_lock<boost::shared_mutex> lock(mutex_);
2519+
if (auto it = unparsed_.find(id); it != unparsed_.end()) {
2520+
std::tie(type, unparsed) = it->second;
2521+
unparsed_.erase(id);
2522+
} else if (auto it = unparsed_.find(flip(id)); it != unparsed_.end()) {
2523+
std::tie(type, unparsed) = it->second;
2524+
unparsed_.erase(flip(id));
2525+
}
25232526
}
25242527

25252528
if (unparsed.empty()) {
@@ -2574,9 +2577,9 @@ boost::shared_ptr<Convention> Conventions::get(const string& id) const {
25742577
}
25752578

25762579
try {
2577-
DLOG("Loading Convention " << id);
2580+
DLOG("Building Convention " << id);
25782581
convention->fromXMLString(unparsed);
2579-
addInternal(convention);
2582+
add(convention);
25802583
} catch (exception& e) {
25812584
QL_FAIL("Required convention '" << id << "' could not be built: " << e.what());
25822585
}
@@ -2639,12 +2642,8 @@ bool Conventions::has(const std::string& id, const Convention::Type& type) const
26392642
return get(id, type).first;
26402643
}
26412644

2642-
void Conventions::add(const boost::shared_ptr<Convention>& convention) {
2645+
void Conventions::add(const boost::shared_ptr<Convention>& convention) const {
26432646
boost::unique_lock<boost::shared_mutex> lock(mutex_);
2644-
addInternal(convention);
2645-
}
2646-
2647-
void Conventions::addInternal(const boost::shared_ptr<Convention>& convention) const {
26482647
const string& id = convention->id();
26492648
QL_REQUIRE(data_.find(id) == data_.end(), "Convention already exists for id " << id);
26502649
data_[id] = convention;

OREData/ored/configuration/conventions.hpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -138,11 +138,11 @@ class Conventions : public XMLSerializable {
138138
bool has(const std::string& id, const Convention::Type& type) const;
139139

140140
/*! Clear all conventions */
141-
void clear();
141+
void clear() const;
142142

143143
/*! Add a convention. This will overwrite an existing convention
144144
with the same id */
145-
void add(const boost::shared_ptr<Convention>& convention);
145+
void add(const boost::shared_ptr<Convention>& convention) const;
146146

147147
//! \name Serialisation
148148
//@{0
@@ -151,8 +151,6 @@ class Conventions : public XMLSerializable {
151151
//@}
152152

153153
private:
154-
void addInternal(const boost::shared_ptr<Convention>& convention) const;
155-
156154
mutable map<string, boost::shared_ptr<Convention>> data_;
157155
mutable map<string, std::pair<string, string>> unparsed_;
158156
mutable boost::shared_mutex mutex_;

0 commit comments

Comments
 (0)