CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
Registry.cc
Go to the documentation of this file.
1 // ----------------------------------------------------------------------
2 // ----------------------------------------------------------------------
3 
4 #include <ostream>
5 
8 
9 namespace edm {
10  namespace pset {
12 
13  Registry*
15  [[cms::thread_safe]] static Registry s_reg;
16  return &s_reg;
17  }
18 
19  bool
21  auto it = m_map.find(k);
22  bool found = it != m_map.end();
23  if(found) {
24  result = it->second;
25  }
26  return found;
27  }
28 
30  Registry::getMapped(key_type const& k) const {
31  auto it = m_map.find(k);
32  bool found = it != m_map.end();
33  return found? &(it->second) : static_cast<value_type const*>(nullptr);
34  }
35 
36  bool
38  return m_map.insert(std::make_pair(v.id(),v)).second;
39  }
40 
41  void
43  m_map.clear();
44  }
45 
46  void
47  Registry::fillMap(regmap_type& fillme) const {
48  fillme.clear();
49  // Note: The tracked part is in the registry.
50  for (auto const& item : m_map) {
51  fillme[item.first].pset() = item.second.toString();
52  }
53  }
54 
55  void
56  Registry::print(std::ostream& os) const {
57  os << "Registry with " << size() << " entries\n";
58  for(auto const& item : *this) {
59  os << item.first << " " << item.second << '\n';
60  }
61  }
62 
63  ParameterSetID const&
67  << "Illegal attempt to access the process top level parameter set ID\n"
68  << "before that parameter set has been frozen and registered.\n"
69  << "The parameter set can be changed during module validation,\n"
70  << "which occurs concurrently with module construction.\n"
71  << "It is illegal to access the parameter set before it is frozen.\n";
72  }
74  }
75 
78  }
79 
80  } // namespace pset
81 
83 
84  if (!pset::s_ProcessParameterSetID.isValid()) {
86  << "Illegal attempt to access the process top level parameter set ID\n"
87  << "before that parameter set has been frozen and registered.\n"
88  << "The parameter set can be changed during module validation,\n"
89  << "which occurs concurrently with module construction.\n"
90  << "It is illegal to access the parameter set before it is frozen.\n";
91  }
92 
94  ParameterSet const* result;
95  if (nullptr == (result = reg.getMapped(pset::s_ProcessParameterSetID))) {
96  throw edm::Exception(errors::EventCorruption, "Unknown ParameterSetID")
97  << "Unable to find the ParameterSet for id: "
99  << ";\nthis was supposed to be the process ParameterSet\n";
100  }
101  return *result;
102  }
103 
104 } // namespace edm
size_t size() const
Definition: Registry.h:77
ParameterSetID id() const
std::map< ParameterSetID, ParameterSetBlob > regmap_type
Definition: Registry.h:83
tuple result
Definition: query.py:137
void clear()
Not thread safe.
Definition: Registry.cc:42
bool getMapped(key_type const &k, value_type &result) const
Definition: Registry.cc:20
void setProcessParameterSetID(ParameterSetID const &id)
Associated free functions.
Definition: Registry.cc:76
static ParameterSetID s_ProcessParameterSetID
Definition: Registry.cc:11
int k[5][pyjets_maxn]
ParameterSet const & getProcessParameterSet()
Definition: Registry.cc:82
bool isValid() const
Definition: Hash.h:150
void print(std::ostream &os) const
Definition: Registry.cc:56
map_type m_map
Definition: Registry.h:89
bool insertMapped(value_type const &v)
Definition: Registry.cc:37
ParameterSetID const & getProcessParameterSetID()
Definition: Registry.cc:64
void fillMap(regmap_type &fillme) const
Definition: Registry.cc:47
static Registry * instance()
Definition: Registry.cc:14