00001 #ifndef IDSOURCE_H_
00002 #define IDSOURCE_H_
00003
00004 #include "TObject.h"
00005 #include <map>
00006 #include <string>
00007 #include "IdChannel.h"
00008 #include "IdGenerator.h"
00009
00010 namespace IDs{
00011 class source;
00012
00013
00014 }
00015
00020 class IDs::source:public TObject{
00021 public:
00024 source()
00025 : fChannel(),fGenerator() {};
00026
00030 source(const std::string& s)
00031 : fChannel(),fGenerator() {
00032 operator=(s);
00033 };
00034
00036 source(const IDs::channel& ch,const IDs::generator& gen)
00037 : fChannel(ch),fGenerator(gen){};
00038
00046 source(const std::string& det, const std::string& type,
00047 const std::string& gen, const std::string& cfg=IDs::kDefaultConfig)
00048 : fChannel(det,type), fGenerator(gen,cfg) {};
00049
00057 source(Detector_t det, SlowFast_t type,const Generator_t& t ,const Config_t& c=IDs::kDefaultConfig)
00058 : fChannel(det,type),fGenerator(t,c){};
00059
00060 virtual ~source(){};
00061
00062 void Reset(){fChannel.Reset(); fGenerator.Reset();}
00063
00065 bool operator==(const source& rhs)const;
00066
00069 bool operator==(const generator& rhs)const{return fGenerator==rhs;};
00070
00072 bool operator==(const channel& rhs)const{return fChannel==rhs;};
00073
00075 bool matches(const source& rhs)const;
00077 bool matches(const generator& rhs)const{return fGenerator.matches(rhs);};
00079 bool matches(const channel& rhs)const{return fChannel.matches(rhs);};
00080
00082 bool operator>(const source& rhs)const;
00084 bool operator<(const source& rhs)const;
00085
00087 generator& Generator(){return fGenerator;};
00088
00090 channel& Channel(){return fChannel;};
00091
00093 const generator& Generator()const{return fGenerator;};
00094
00096 const channel& Channel()const{return fChannel;};
00097
00099 std::string str(bool cpp_valid=false)const;
00100
00101 IDs::source& operator=(const std::string& rhs);
00102
00104 bool isWildCardChannel() const {return Channel().isWildCard();}
00105
00107 bool isWildCardGenerator() const {return Generator().isWildCard();}
00108
00112 bool isWildCard() const
00113 {return isWildCardChannel() || isWildCardGenerator();}
00114
00116 bool isFast() const {return Channel().isFast();};
00117
00119 bool isSlow() const {return Channel().isSlow();};
00120
00122 void Debug()const;
00123
00124 private:
00125 channel fChannel;
00126 generator fGenerator;
00127
00128 ClassDef(source,1);
00129 };
00130
00131 inline bool IDs::source::operator==(const source& rhs)const
00132 {
00133 return rhs.Generator()==fGenerator && rhs.Channel()==fChannel;
00134 }
00135 inline bool IDs::source::matches(const source& rhs)const{
00136 return fGenerator.matches(rhs.fGenerator) && fChannel.matches(rhs.fChannel);
00137 }
00138
00139 inline bool IDs::source::operator>(const source& rhs)const
00140 {
00141 return fChannel>rhs.Channel() || (fChannel==rhs.Channel() && fGenerator > rhs.Generator());
00142 }
00143
00144 inline bool IDs::source::operator<(const source& rhs)const
00145 {
00146 return fChannel<rhs.Channel() || (fChannel==rhs.Channel() && fGenerator < rhs.Generator());
00147 }
00148
00149 ostream& operator<< (ostream& os ,const IDs::source& id);
00150
00151 #endif // IDSOURCE_H_
00152
00153
00154
00155
00156
00157