CMS 3D CMS Logo

/data/doxygen/doxygen-1.7.3/gen/CMSSW_4_2_8/src/DetectorDescription/Base/interface/DDReadMapType.h

Go to the documentation of this file.
00001 #ifndef DD_READMAPTYPE_H
00002 #define DD_READMAPTYPE_H
00003 
00004 // #include <iostream>
00005 #include <string>
00006 #include <map>
00007 #include "DetectorDescription/Base/interface/DDException.h"
00008 
00009 // class DDException;
00010 
00011 namespace dddDetails {
00012   void errorReadMapType(const std::string & key) throw (DDException);
00013 }
00014 
00016 
00017 template<class V> class ReadMapType : public std::map<std::string,V>
00018 {
00019  public:
00020   ReadMapType() : std::map<std::string,V>() {}
00021 
00022   const V & operator[](const std::string & key) const throw (DDException)
00023    { 
00024       typename std::map<std::string,V>::const_iterator it = this->find(key); 
00025       if (it == this->end()) dddDetails::errorReadMapType(key);
00026       return it->second;
00027    }
00028    
00029 
00030    V & operator[](const std::string & key)
00031    {
00032       //std::cout << "non-const-called" << std::endl;
00033       return std::map<std::string,V>::operator[](key);
00034    }
00035   
00036 private:
00037 
00038 };
00039 
00040 #endif // DD_READMAPTYE_H