00001 #ifndef DQMOFFLINE_TRIGGER_COMCODES 00002 #define DQMOFFLINE_TRIGGER_COMCODES 00003 00004 #include <cstring> 00005 #include <map> 00006 #include <string> 00007 #include <vector> 00008 #include <iostream> 00009 00010 //used to be ComCodesBase, however changed the design that instead of inheriting from this class, all my communication classes 00011 //would own an object of this class 00012 //this has the added advantage that they can all be declered static and I wasnt using any of the inheritance features anyway 00013 //this class is basically a map which stores the communication bit codes and their names so they can be accessed easily 00014 class ComCodes { 00015 00016 private: 00017 //std::map<std::string,int> _codeDefs; 00018 std::vector<std::pair<std::string,int> > _codeDefs; 00019 00020 public: 00021 ComCodes(){} 00022 ComCodes(const ComCodes& rhs):_codeDefs(rhs._codeDefs){} 00023 ~ComCodes(){} 00024 00025 //accessors 00026 int getCode(const char *descript)const; 00027 void getCodeName(int code,std::string& id)const; 00028 00029 //modifiers 00030 void setCode(const char *descript,int code); 00031 00032 //key comp 00033 static bool keyComp(const std::pair<std::string,int>& lhs,const std::pair<std::string,int>& rhs); 00034 void sort(){std::sort(_codeDefs.begin(),_codeDefs.end(),keyComp);} 00035 00036 }; 00037 00038 #endif