/data3/calcul/jacquem/working_dir/Micromegas/micromegasFrameWork/lcio/src/cpp/src/IMPL/LCParametersImpl.cc

Go to the documentation of this file.
00001 #include "IMPL/LCParametersImpl.h"
00002 
00003 #include "LCIOSTLTypes.h"
00004 #include <algorithm>
00005 
00006 using namespace EVENT ;
00007 
00008 namespace IMPL{
00009 
00010   LCParametersImpl::LCParametersImpl(){
00011     
00012   }
00013 
00014   int LCParametersImpl::getIntVal(const std::string & key) const {
00015     
00016     IntMap::iterator it = _intMap.find( key ) ;
00017 
00018     if( it == _intMap.end() )  return 0 ;
00019 
00020     IntVec &  iv =  it->second ;
00021 
00022     return iv[0] ;
00023   }
00024 
00025   float LCParametersImpl::getFloatVal(const std::string & key) const {
00026 
00027     FloatMap::iterator it = _floatMap.find( key ) ;
00028 
00029     if( it == _floatMap.end() )  return 0 ;
00030 
00031     FloatVec &  fv =  it->second ;
00032 
00033     return fv[0] ;
00034   }
00035 
00036   const std::string & LCParametersImpl::getStringVal(const std::string & key) const {
00037 
00038     static std::string empty("") ;
00039     
00040     StringMap::iterator it = _stringMap.find( key ) ;
00041     
00042     if( it == _stringMap.end() )  return empty ;
00043     
00044     StringVec &  sv =  it->second ;
00045     
00046     return sv[0] ;
00047   }
00048 
00049   IntVec & LCParametersImpl::getIntVals(const std::string & key, IntVec & values) const {
00050 
00051     IntMap::iterator it = _intMap.find( key ) ;
00052 
00053     if( it != _intMap.end() ) {
00054       values.insert( values.end() , it->second.begin() , it->second.end() ) ;
00055     }
00056 
00057     return values ;
00058   }
00059 
00060   FloatVec & LCParametersImpl::getFloatVals(const std::string & key, FloatVec & values) const {
00061 
00062     FloatMap::iterator it = _floatMap.find( key ) ;
00063 
00064     if( it != _floatMap.end() ) {
00065       values.insert( values.end() , it->second.begin() , it->second.end() ) ;
00066     }
00067     return values ;
00068   }
00069 
00070   StringVec & LCParametersImpl::getStringVals(const std::string & key, StringVec & values) const {
00071 
00072     StringMap::iterator it = _stringMap.find( key ) ;
00073 
00074     if( it != _stringMap.end() ) {
00075       values.insert( values.end() , it->second.begin() , it->second.end() ) ;
00076     }
00077     return values ;
00078   }
00079 
00080 
00081   const StringVec & LCParametersImpl::getIntKeys(StringVec & keys) const  {
00082 
00083      for( IntMap::iterator iter = _intMap.begin() ; iter !=  _intMap.end() ; iter++ ){
00084        keys.push_back( iter->first ) ; 
00085      }
00086 // fg: select1st is non-standard 
00087 //    transform( _intMap.begin() , _intMap.end() , back_inserter( keys )  , select1st< IntMap::value_type >() ) ;
00088 
00089   return keys ;
00090   }
00091 
00092   const StringVec & LCParametersImpl::getFloatKeys(StringVec & keys) const  {
00093     
00094      for( FloatMap::iterator iter = _floatMap.begin() ; iter !=  _floatMap.end() ; iter++ ){
00095        keys.push_back( iter->first ) ; 
00096      }
00097 // fg: select1st is non-standard
00098 //    transform( _floatMap.begin() , _floatMap.end() , back_inserter( keys )  , select1st< FloatMap::value_type >() ) ;
00099     return keys ;
00100   }
00101 
00102   const StringVec & LCParametersImpl::getStringKeys(StringVec & keys) const  {
00103 
00104     for( StringMap::iterator iter = _stringMap.begin() ; iter !=  _stringMap.end() ; iter++ ){
00105       keys.push_back( iter->first ) ; 
00106     }
00107 // fg: select1st is non-standard
00108 //    transform( _stringMap.begin() , _stringMap.end() , back_inserter( keys )  , select1st< StringMap::value_type >() ) ;
00109     return keys ;
00110   }
00111   
00112   int LCParametersImpl::getNInt(const std::string & key) const {
00113 
00114     IntMap::iterator it = _intMap.find( key ) ;
00115 
00116     if( it == _intMap.end() )
00117       return 0 ;
00118     else
00119       return it->second.size() ;
00120   }
00121 
00122   int LCParametersImpl::getNFloat(const std::string & key) const {
00123 
00124     FloatMap::iterator it = _floatMap.find( key ) ;
00125 
00126     if( it == _floatMap.end() )  
00127       return 0 ;
00128     else
00129       return it->second.size() ;
00130   }
00131 
00132   int LCParametersImpl::getNString(const std::string & key) const {
00133 
00134     StringMap::iterator it = _stringMap.find( key ) ;
00135 
00136     if( it == _stringMap.end() )  
00137       return 0 ;
00138     else
00139       return it->second.size() ;
00140   }
00141 
00142   void LCParametersImpl::setValue(const std::string & key, int value){
00143     checkAccess("LCParametersImpl::setValue") ;
00144 //     if(  _intMap[ key ].size() > 0 ) 
00145     _intMap[ key ].clear() ;
00146     _intMap[ key ].push_back( value ) ;
00147   }
00148 
00149   void LCParametersImpl::setValue(const std::string & key, float value){
00150     checkAccess("LCParametersImpl::setValue") ;
00151 //     if(  _floatMap[ key ].size() > 0 ) 
00152     _floatMap[ key ].clear() ;
00153     _floatMap[ key ].push_back( value ) ;
00154   }
00155 
00156   void LCParametersImpl::setValue(const std::string & key, const std::string & value) {
00157     checkAccess("LCParametersImpl::setValue") ;
00158 //     if(  _stringMap[ key ].size() > 0 ) 
00159     _stringMap[ key ].clear() ;
00160     _stringMap[ key ].push_back( value ) ;
00161 
00162   }
00163 
00164 
00165 
00166   void LCParametersImpl::setValues(const std::string & key,const EVENT::IntVec & values){
00167     
00168     checkAccess("LCParametersImpl::setValues") ;
00169 
00170 //     if(  _intMap[ key ].size() > 0 ) _intMap[ key ].clear() ;
00171 //     copy( values.begin() , values.end() , back_inserter(  _intMap[ key ] )  ) ;
00172 
00173     _intMap[ key ].assign(  values.begin() , values.end() ) ;
00174   }
00175   
00176   void LCParametersImpl::setValues(const std::string & key,const  EVENT::FloatVec & values){
00177 
00178     checkAccess("LCParametersImpl::setValues") ;
00179 
00180 //     if(  _floatMap[ key ].size() > 0 ) _floatMap[ key ].clear() ;
00181 //     copy( values.begin() , values.end() , back_inserter(  _floatMap[ key ] )  ) ;
00182 
00183     _floatMap[ key ].assign(  values.begin() , values.end() ) ;
00184   }
00185   
00186   void LCParametersImpl::setValues(const std::string & key, const EVENT::StringVec & values){
00187 
00188     checkAccess("LCParametersImpl::setValues") ;
00189 
00190 //     if(  _stringMap[ key ].size() > 0 ) _stringMap[ key ].clear() ;
00191 //     copy( values.begin() , values.end() , back_inserter(  _stringMap[ key ] )  ) ;
00192 
00193     _stringMap[ key ].assign(  values.begin() , values.end() ) ;
00194   }
00195 
00196 } // namespace 

Generated on Mon Jan 7 13:15:21 2013 for MicromegasFramework by  doxygen 1.4.7