CMS 3D CMS Logo

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