CMS 3D CMS Logo

Registry.h
Go to the documentation of this file.
1 #ifndef FWCore_ParameterSet_Registry_h
2 #define FWCore_ParameterSet_Registry_h
3 
4 // ----------------------------------------------------------------------
5 // Declaration for pset::Registry. This is an implementation detail of
6 // the ParameterSet library.
7 //
8 // A Registry is used to keep track of the persistent form of all
9 // ParameterSets used a given program, so that they may be retrieved by
10 // ParameterSetID, and so they may be written to persistent storage.
11 // Note that this registry is *not* directly persistable. The contents
12 // are persisted, but not the container.
13 // ----------------------------------------------------------------------
14 
15 #include <iosfwd>
16 #include <map>
17 #include "tbb/concurrent_unordered_map.h"
18 
22 
23 namespace edm {
24  namespace pset {
25 
26  class Registry {
27  public:
30 
31  static Registry* instance();
32 
38  bool getMapped(key_type const& k, value_type& result) const;
39 
43  value_type const* getMapped(key_type const& k) const;
44 
52  bool insertMapped(value_type const& v, bool forceUpdate = false);
53 
55  void clear();
56 
57  struct key_hash {
58  std::size_t operator()(key_type const& iKey) const{
59  return iKey.smallHash();
60  }
61  };
62  typedef tbb::concurrent_unordered_map<key_type,value_type,key_hash> map_type;
63  typedef map_type::const_iterator const_iterator;
64 
65  const_iterator begin() const {
66  return m_map.begin();
67  }
68 
69  const_iterator end() const {
70  return m_map.end();
71  }
72 
73  bool empty() const {
74  return m_map.empty();
75  }
76 
77  size_t size() const {
78  return m_map.size();
79  }
80 
83  typedef std::map<ParameterSetID, ParameterSetBlob> regmap_type;
84  void fillMap(regmap_type& fillme) const;
85 
86  void print(std::ostream& os) const;
87 
88  private:
89  map_type m_map;
90  };
91 
92  } // namespace pset
93 } // namespace edm
94 
95 #endif
size_t size() const
Definition: Registry.h:77
map_type::const_iterator const_iterator
Definition: Registry.h:63
const_iterator end() const
Definition: Registry.h:69
std::map< ParameterSetID, ParameterSetBlob > regmap_type
Definition: Registry.h:83
bool empty() const
Definition: Registry.h:73
std::size_t operator()(key_type const &iKey) const
Definition: Registry.h:58
edm::ParameterSet value_type
Definition: Registry.h:29
void clear()
Not thread safe.
Definition: Registry.cc:44
const_iterator begin() const
Definition: Registry.h:65
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]
tbb::concurrent_unordered_map< key_type, value_type, key_hash > map_type
Definition: Registry.h:62
edm::ParameterSetID key_type
Definition: Registry.h:28
size_t smallHash() const
returns a short hash which can be used with hashing containers
Definition: Hash.h:221
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