1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
|
// ----------------------------------------------------------------------
// ----------------------------------------------------------------------
#include <ostream>
#include "FWCore/ParameterSet/interface/Registry.h"
#include "FWCore/Utilities/interface/thread_safety_macros.h"
namespace edm {
namespace pset {
Registry* Registry::instance() {
CMS_THREAD_SAFE static Registry s_reg;
return &s_reg;
}
bool Registry::getMapped(key_type const& k, value_type& result) const {
auto it = m_map.find(k);
bool found = it != m_map.end();
if (found) {
result = it->second;
}
return found;
}
Registry::value_type const* Registry::getMapped(key_type const& k) const {
auto it = m_map.find(k);
bool found = it != m_map.end();
return found ? &(it->second) : static_cast<value_type const*>(nullptr);
}
bool Registry::insertMapped(value_type const& v, bool forceUpdate) {
auto wasAdded = m_map.insert(std::make_pair(v.id(), v));
if (forceUpdate and not wasAdded.second) {
wasAdded.first->second = v;
}
return wasAdded.second;
}
void Registry::clear() { m_map.clear(); }
void Registry::fillMap(regmap_type& fillme) const {
fillme.clear();
// Note: The tracked part is in the registry.
for (auto const& item : m_map) {
fillme[item.first].pset() = item.second.toString();
}
}
void Registry::print(std::ostream& os) const {
os << "Registry with " << size() << " entries\n";
for (auto const& item : *this) {
os << item.first << " " << item.second << '\n';
}
}
} // namespace pset
} // namespace edm
|