CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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);
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 
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:
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
tuple result
Definition: mps_fire.py:95
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:40
const_iterator begin() const
Definition: Registry.h:65
bool getMapped(key_type const &k, value_type &result) const
Definition: Registry.cc:18
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:220
void print(std::ostream &os) const
Definition: Registry.cc:54
map_type m_map
Definition: Registry.h:89
bool insertMapped(value_type const &v)
Definition: Registry.cc:35
void fillMap(regmap_type &fillme) const
Definition: Registry.cc:45
static Registry * instance()
Definition: Registry.cc:12