CMS 3D CMS Logo

Registry.cc
Go to the documentation of this file.
1 // ----------------------------------------------------------------------
2 // ----------------------------------------------------------------------
3 
4 #include <ostream>
5 
7 
8 namespace edm {
9  namespace pset {
10 
11  Registry*
13  [[cms::thread_safe]] static Registry s_reg;
14  return &s_reg;
15  }
16 
17  bool
19  auto it = m_map.find(k);
20  bool found = it != m_map.end();
21  if(found) {
22  result = it->second;
23  }
24  return found;
25  }
26 
28  Registry::getMapped(key_type const& k) const {
29  auto it = m_map.find(k);
30  bool found = it != m_map.end();
31  return found? &(it->second) : static_cast<value_type const*>(nullptr);
32  }
33 
34  bool
35  Registry::insertMapped(value_type const& v, bool forceUpdate) {
36  auto wasAdded = m_map.insert(std::make_pair(v.id(),v));
37  if(forceUpdate and not wasAdded.second) {
38  wasAdded.first->second = v;
39  }
40  return wasAdded.second;
41  }
42 
43  void
45  m_map.clear();
46  }
47 
48  void
49  Registry::fillMap(regmap_type& fillme) const {
50  fillme.clear();
51  // Note: The tracked part is in the registry.
52  for (auto const& item : m_map) {
53  fillme[item.first].pset() = item.second.toString();
54  }
55  }
56 
57  void
58  Registry::print(std::ostream& os) const {
59  os << "Registry with " << size() << " entries\n";
60  for(auto const& item : *this) {
61  os << item.first << " " << item.second << '\n';
62  }
63  }
64  } // namespace pset
65 } // namespace edm
size_t size() const
Definition: Registry.h:77
ParameterSetID id() const
std::map< ParameterSetID, ParameterSetBlob > regmap_type
Definition: Registry.h:83
void clear()
Not thread safe.
Definition: Registry.cc:44
bool getMapped(key_type const &k, value_type &result) const
Definition: Registry.cc:18
bool insertMapped(value_type const &v, bool forceUpdate=false)
Definition: Registry.cc:35
int k[5][pyjets_maxn]
HLT enums.
void print(std::ostream &os) const
Definition: Registry.cc:58
map_type m_map
Definition: Registry.h:89
void fillMap(regmap_type &fillme) const
Definition: Registry.cc:49
static Registry * instance()
Definition: Registry.cc:12