/data3/calcul/jacquem/working_dir/Micromegas/micromegasFrameWork/lcio/src/cpp/src/UTIL/IndexMap.cc

Go to the documentation of this file.
00001 #include "UTIL/IndexMap.h"
00002 
00003 ////////////////////////////////////////////////////////////////////////////////
00004 // EXP: UNDER DEVELOPMENT!!!
00005 ////////////////////////////////////////////////////////////////////////////////
00006 
00007 using namespace EVENT;
00008 
00009 namespace UTIL{
00010   
00011   IndexMap::IndexMap(const EVENT::LCCollection* col, const std::string& key1, const std::string& key2): _col(col), _key1(key1), _key2(key2){
00012     _col->getParameters().getStringVals( key1, _strvec );
00013     _col->getParameters().getIntVals( key2, _intvec );
00014 
00015     throw Exception("  IndexMap still under development  - sorry !!!!  ") ;
00016   }
00017 
00018   IndexMap::~IndexMap(){}
00019 
00020   int IndexMap::encode(const std::string name){
00021     int type=-1;
00022     for( unsigned int i=0; i<_strvec.size(); i++ ){
00023       if(_strvec[i]==name)
00024         type = _intvec[i];
00025     }
00026     //type wasn't found and has to be added to collection
00027     if(type == -1){
00028       type = _strvec.size()+1;
00029       
00030       //add new type to the corresponding vectors
00031       _strvec.push_back( name );
00032       _intvec.push_back( type );
00033 
00034       //update col->parameters()
00035       const_cast<LCCollection*>(_col)->parameters().setValues(_key1,_strvec);
00036       const_cast<LCCollection*>(_col)->parameters().setValues(_key2,_intvec);
00037     }
00038     return type;
00039   }
00040   
00041   const std::string& IndexMap::decode(int type) const{
00042     for( unsigned int i=0; i<_intvec.size(); i++ ){
00043       if(_intvec[i]==type)
00044         return _strvec[i];
00045     }
00046     //type not found in collection
00047     static const std::string str="Unknown type!!!";
00048     return str;
00049   }
00050 
00051 } // namespace
00052  

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