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 { return iKey.smallHash(); }
59  };
60  typedef tbb::concurrent_unordered_map<key_type, value_type, key_hash> map_type;
61  typedef map_type::const_iterator const_iterator;
62 
63  const_iterator begin() const { return m_map.begin(); }
64 
65  const_iterator end() const { return m_map.end(); }
66 
67  bool empty() const { return m_map.empty(); }
68 
69  size_t size() const { return m_map.size(); }
70 
73  typedef std::map<ParameterSetID, ParameterSetBlob> regmap_type;
74  void fillMap(regmap_type& fillme) const;
75 
76  void print(std::ostream& os) const;
77 
78  private:
79  map_type m_map;
80  };
81 
82  } // namespace pset
83 } // namespace edm
84 
85 #endif
size_t size() const
Definition: Registry.h:69
map_type::const_iterator const_iterator
Definition: Registry.h:61
const_iterator end() const
Definition: Registry.h:65
std::map< ParameterSetID, ParameterSetBlob > regmap_type
Definition: Registry.h:73
bool empty() const
Definition: Registry.h:67
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:63
bool getMapped(key_type const &k, value_type &result) const
Definition: Registry.cc:17
bool insertMapped(value_type const &v, bool forceUpdate=false)
Definition: Registry.cc:32
int k[5][pyjets_maxn]
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:224
HLT enums.
tbb::concurrent_unordered_map< key_type, value_type, key_hash > map_type
Definition: Registry.h:60
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