CMS 3D CMS Logo

List of all members | Public Member Functions | Static Public Member Functions | Private Attributes
egHLT::ComCodes Class Reference

#include <EgHLTComCodes.h>

Public Member Functions

 ComCodes ()
 
 ComCodes (const ComCodes &rhs)
 
int getCode (const char *descript) const
 
void getCodeName (int code, std::string &id) const
 
void setCode (const char *descript, int code)
 
void sort ()
 
 ~ComCodes ()
 

Static Public Member Functions

static bool keyComp (const std::pair< std::string, int > &lhs, const std::pair< std::string, int > &rhs)
 

Private Attributes

std::vector< std::pair< std::string, int > > _codeDefs
 

Detailed Description

Definition at line 12 of file EgHLTComCodes.h.

Constructor & Destructor Documentation

egHLT::ComCodes::ComCodes ( )
inline

Definition at line 18 of file EgHLTComCodes.h.

18 {}
egHLT::ComCodes::ComCodes ( const ComCodes rhs)
inline

Definition at line 19 of file EgHLTComCodes.h.

19 :_codeDefs(rhs._codeDefs){}
std::vector< std::pair< std::string, int > > _codeDefs
Definition: EgHLTComCodes.h:15
egHLT::ComCodes::~ComCodes ( )
inline

Member Function Documentation

int ComCodes::getCode ( const char *  descript) const

Definition at line 20 of file EgHLTComCodes.cc.

References _codeDefs, plotBeamSpotDB::first, runEdmFileComparison::found, i, and NULL.

Referenced by egHLT::EgCutCodes::getCode(), and ~ComCodes().

21 {
22  //first copy the character string to a local array so we can manipulate it
23  char localDescript[256];
24  strcpy(localDescript,descript);
25 
26  int code = 0x0000;
27  char* codeKey = strtok(localDescript,":");
28  // std::map<std::string,int> ::const_iterator mapIt;
29  while(codeKey!=NULL){
30  bool found=false;
31 
32  for(size_t i=0;i<_codeDefs.size() && !found;i++){
33  if(_codeDefs[i].first.compare(codeKey)==0){
34  found=true;
35  code |= _codeDefs[i].second;
36 
37  }
38  }
39 
40  if(!found) edm::LogWarning("EgHLTComCodes") <<"ComCodes::getCode : Error, Key "<<codeKey<<" not found (likely mistyped, practical upshot is the selection is not what you think it is)";//<<std::endl;
41  codeKey = strtok(NULL,":"); //getting new substring
42 
43  }
44  return code;
45 }
int i
Definition: DBlmapReader.cc:9
#define NULL
Definition: scimark2.h:8
std::vector< std::pair< std::string, int > > _codeDefs
Definition: EgHLTComCodes.h:15
void ComCodes::getCodeName ( int  code,
std::string &  id 
) const

Definition at line 52 of file EgHLTComCodes.cc.

References _codeDefs, relativeConstraints::empty, i, and edm::second().

Referenced by egHLT::EgCutCodes::getCodeName(), and ~ComCodes().

53 {
54  id.clear();
55  for(size_t i=0;i<_codeDefs.size();i++){
56  if((code&_codeDefs[i].second)==_codeDefs[i].second){
57  if(!id.empty()) id+=":";//seperating entries by a ':'
58  id+=_codeDefs[i].first;
59  }
60 
61  }
62 
63 }
int i
Definition: DBlmapReader.cc:9
U second(std::pair< T, U > const &p)
std::vector< std::pair< std::string, int > > _codeDefs
Definition: EgHLTComCodes.h:15
bool ComCodes::keyComp ( const std::pair< std::string, int > &  lhs,
const std::pair< std::string, int > &  rhs 
)
static

Definition at line 47 of file EgHLTComCodes.cc.

Referenced by sort(), and ~ComCodes().

48 {
49  return lhs.first < rhs.first;
50 }
void ComCodes::setCode ( const char *  descript,
int  code 
)

Definition at line 7 of file EgHLTComCodes.cc.

References _codeDefs, plotBeamSpotDB::first, runEdmFileComparison::found, and i.

Referenced by egHLT::EgCutCodes::setCodes_(), and ~ComCodes().

8 {
9  bool found=false;
10  for(size_t i=0;i<_codeDefs.size() && !found;i++){
11  if(_codeDefs[i].first.compare(descript)==0) found=true;
12  }
13  if(!found) _codeDefs.push_back(std::pair<std::string,int>(descript,code));
14 
15  //_codeDefs[descript] = code;
16 }
int i
Definition: DBlmapReader.cc:9
std::vector< std::pair< std::string, int > > _codeDefs
Definition: EgHLTComCodes.h:15
void egHLT::ComCodes::sort ( )
inline

Definition at line 31 of file EgHLTComCodes.h.

References keyComp().

Referenced by egHLT::EgCutCodes::setCodes_().

31 {std::sort(_codeDefs.begin(),_codeDefs.end(),keyComp);}
std::vector< std::pair< std::string, int > > _codeDefs
Definition: EgHLTComCodes.h:15
static bool keyComp(const std::pair< std::string, int > &lhs, const std::pair< std::string, int > &rhs)

Member Data Documentation

std::vector<std::pair<std::string,int> > egHLT::ComCodes::_codeDefs
private

Definition at line 15 of file EgHLTComCodes.h.

Referenced by getCode(), getCodeName(), and setCode().