CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
DDReadMapType.h
Go to the documentation of this file.
1 #ifndef DD_READMAPTYPE_H
2 #define DD_READMAPTYPE_H
3 
4 #include <string>
5 #include <map>
6 
7 namespace dddDetails {
8  void errorReadMapType(const std::string & key);
9 }
10 
12 
13 template<class V> class ReadMapType : public std::map<std::string,V>
14 {
15  public:
16  ReadMapType() : std::map<std::string,V>() {}
17 
18  const V & operator[](const std::string & key) const
19  {
20  typename std::map<std::string,V>::const_iterator it = this->find(key);
21  if (it == this->end()) dddDetails::errorReadMapType(key);
22  return it->second;
23  }
24 
25  V & operator[](const std::string & key)
26  {
27  return std::map<std::string,V>::operator[](key);
28  }
29 };
30 
31 #endif // DD_READMAPTYE_H
const V & operator[](const std::string &key) const
Definition: DDReadMapType.h:18
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:7
a std::map&lt;std::string,YourType&gt; that offers a const operator[key]; if key is not stored in the std::...
Definition: DDReadMapType.h:13
V & operator[](const std::string &key)
Definition: DDReadMapType.h:25
#define end
Definition: vmac.h:38
void errorReadMapType(const std::string &key)
Definition: DDReadMapType.cc:5
list key
Definition: combine.py:13