CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
Registry.cc
Go to the documentation of this file.
1 // ----------------------------------------------------------------------
2 // ----------------------------------------------------------------------
3 
4 #include <ostream>
5 
8 
9 namespace edm {
10  namespace pset {
11 
13  CMS_THREAD_SAFE static Registry s_reg;
14  return &s_reg;
15  }
16 
18  auto it = m_map.find(k);
19  bool found = it != m_map.end();
20  if (found) {
21  result = it->second;
22  }
23  return found;
24  }
25 
27  auto it = m_map.find(k);
28  bool found = it != m_map.end();
29  return found ? &(it->second) : static_cast<value_type const*>(nullptr);
30  }
31 
32  bool Registry::insertMapped(value_type const& v, bool forceUpdate) {
33  auto wasAdded = m_map.insert(std::make_pair(v.id(), v));
34  if (forceUpdate and not wasAdded.second) {
35  wasAdded.first->second = v;
36  }
37  return wasAdded.second;
38  }
39 
40  void Registry::clear() { m_map.clear(); }
41 
42  void Registry::fillMap(regmap_type& fillme) const {
43  fillme.clear();
44  // Note: The tracked part is in the registry.
45  for (auto const& item : m_map) {
46  fillme[item.first].pset() = item.second.toString();
47  }
48  }
49 
50  void Registry::print(std::ostream& os) const {
51  os << "Registry with " << size() << " entries\n";
52  for (auto const& item : *this) {
53  os << item.first << " " << item.second << '\n';
54  }
55  }
56  } // namespace pset
57 } // namespace edm
size_t size() const
Definition: Registry.h:69
ParameterSetID id() const
std::map< ParameterSetID, ParameterSetBlob > regmap_type
Definition: Registry.h:73
tuple result
Definition: mps_fire.py:311
void clear()
Not thread safe.
Definition: Registry.cc:40
bool getMapped(key_type const &k, value_type &result) const
Definition: Registry.cc:17
#define CMS_THREAD_SAFE
bool insertMapped(value_type const &v, bool forceUpdate=false)
Definition: Registry.cc:32
void print(std::ostream &os) const
Definition: Registry.cc:50
map_type m_map
Definition: Registry.h:79
void fillMap(regmap_type &fillme) const
Definition: Registry.cc:42
static Registry * instance()
Definition: Registry.cc:12