LCIO  02.17
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
IndexMap.cc
Go to the documentation of this file.
1 #include "UTIL/IndexMap.h"
2 #include "Exceptions.h"
3 
5 // EXP: UNDER DEVELOPMENT!!!
7 
8 using namespace EVENT;
9 
10 namespace UTIL{
11 
12  IndexMap::IndexMap(const EVENT::LCCollection* col, const std::string& key1, const std::string& key2): _col(col), _key1(key1), _key2(key2){
15 
16  throw Exception(" IndexMap still under development - sorry !!!! ") ;
17  }
18 
20 
21  int IndexMap::encode(const std::string name){
22  int type=-1;
23  for( unsigned int i=0; i<_strvec.size(); i++ ){
24  if(_strvec[i]==name)
25  type = _intvec[i];
26  }
27  //type wasn't found and has to be added to collection
28  if(type == -1){
29  type = _strvec.size()+1;
30 
31  //add new type to the corresponding vectors
32  _strvec.push_back( name );
33  _intvec.push_back( type );
34 
35  //update col->parameters()
36  const_cast<LCCollection*>(_col)->parameters().setValues(_key1,_strvec);
37  const_cast<LCCollection*>(_col)->parameters().setValues(_key2,_intvec);
38  }
39  return type;
40  }
41 
42  const std::string& IndexMap::decode(int type) const{
43  for( unsigned int i=0; i<_intvec.size(); i++ ){
44  if(_intvec[i]==type)
45  return _strvec[i];
46  }
47  //type not found in collection
48  static const std::string str="Unknown type!!!";
49  return str;
50  }
51 
52 } // namespace
53 
const std::string & decode(int type) const
decode int to string (e.g.
Definition: IndexMap.cc:42
Base exception class for LCIO - all other exceptions extend this.
Definition: Exceptions.h:21
const std::string _key2
Definition: IndexMap.h:77
int encode(const std::string name)
encode string to index (e.g.
Definition: IndexMap.cc:21
std::map< std::string, EVENT::IntVec * > IndexMap
Definition: TrackImpl.h:14
EVENT::StringVec _strvec
Definition: IndexMap.h:78
STL class.
T push_back(T...args)
const std::string _key1
Definition: IndexMap.h:76
T size(T...args)
virtual StringVec & getStringVals(const std::string &key, StringVec &values) const =0
Adds all string values for the given key to values.
The generic collection used in LCIO.
Definition: LCCollection.h:29
virtual IntVec & getIntVals(const std::string &key, IntVec &values) const =0
Adds all integer values for the given key to values.
virtual const LCParameters & getParameters() const =0
Parameters defined for this collection.
const EVENT::LCCollection * _col
Definition: IndexMap.h:75
EVENT::IntVec _intvec
Definition: IndexMap.h:79