Skip to content

Commit 5108573

Browse files
pcaspersjenkins
authored andcommitted
QPR-11524 write out used conventions only
1 parent cbd7c1b commit 5108573

2 files changed

Lines changed: 19 additions & 6 deletions

File tree

OREData/ored/configuration/conventions.cpp

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2471,7 +2471,8 @@ XMLNode* Conventions::toXML(XMLDocument& doc) {
24712471

24722472
map<string, boost::shared_ptr<Convention>>::const_iterator it;
24732473
for (it = data_.begin(); it != data_.end(); ++it) {
2474-
XMLUtils::appendNode(conventionsNode, data_[it->first]->toXML(doc));
2474+
if (used_.find(it->first) != used_.end())
2475+
XMLUtils::appendNode(conventionsNode, it->second->toXML(doc));
24752476
}
24762477
return conventionsNode;
24772478
}
@@ -2507,10 +2508,14 @@ boost::shared_ptr<Convention> Conventions::get(const string& id) const {
25072508

25082509
{
25092510
boost::shared_lock<boost::shared_mutex> lock(mutex_);
2510-
if (auto it = data_.find(id); it != data_.end())
2511+
if (auto it = data_.find(id); it != data_.end()) {
2512+
used_.insert(id);
25112513
return it->second;
2512-
if (auto it = data_.find(flip(id)); it != data_.end())
2514+
}
2515+
if (auto it = data_.find(flip(id)); it != data_.end()) {
2516+
used_.insert(flip(id));
25132517
return it->second;
2518+
}
25142519
}
25152520

25162521
std::string type, unparsed;
@@ -2580,6 +2585,7 @@ boost::shared_ptr<Convention> Conventions::get(const string& id) const {
25802585
DLOG("Building Convention " << id);
25812586
convention->fromXMLString(unparsed);
25822587
add(convention);
2588+
used_.insert(id);
25832589
} catch (exception& e) {
25842590
QL_FAIL("Required convention '" << id << "' could not be built: " << e.what());
25852591
}
@@ -2594,8 +2600,10 @@ boost::shared_ptr<Convention> Conventions::getFxConvention(const string& ccy1, c
25942600
if (fxCon) {
25952601
string source = fxCon->sourceCurrency().code();
25962602
string target = fxCon->targetCurrency().code();
2597-
if ((source == ccy1 && target == ccy2) || (target == ccy1 && source == ccy2))
2603+
if ((source == ccy1 && target == ccy2) || (target == ccy1 && source == ccy2)) {
2604+
used_.insert(c.first);
25982605
return fxCon;
2606+
}
25992607
}
26002608
}
26012609
QL_FAIL("Required FX convention for ccys '" << ccy1 << "' and '" << ccy2 << "' not found.");
@@ -2604,8 +2612,10 @@ boost::shared_ptr<Convention> Conventions::getFxConvention(const string& ccy1, c
26042612
pair<bool, boost::shared_ptr<Convention>> Conventions::get(const string& id, const Convention::Type& type) const {
26052613
try {
26062614
auto c = get(id);
2607-
if (c->type() == type)
2615+
if (c->type() == type) {
2616+
used_.insert(id);
26082617
return std::make_pair(true, c);
2618+
}
26092619
} catch (...) {
26102620
}
26112621
return make_pair(false, nullptr);
@@ -2618,8 +2628,10 @@ std::set<boost::shared_ptr<Convention>> Conventions::get(const Convention::Type&
26182628
{
26192629
boost::shared_lock<boost::shared_mutex> lock(mutex_);
26202630
for (auto const& d : data_) {
2621-
if (d.second->type() == type)
2631+
if (d.second->type() == type) {
2632+
used_.insert(d.first);
26222633
result.insert(d.second);
2634+
}
26232635
}
26242636
for (auto const& u : unparsed_) {
26252637
if (u.second.first == typeStr)

OREData/ored/configuration/conventions.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,7 @@ class Conventions : public XMLSerializable {
153153
private:
154154
mutable map<string, boost::shared_ptr<Convention>> data_;
155155
mutable map<string, std::pair<string, string>> unparsed_;
156+
std::set<string> used_;
156157
mutable boost::shared_mutex mutex_;
157158
};
158159

0 commit comments

Comments
 (0)