00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039 #ifndef G4ITTYPE_HH
00040 #define G4ITTYPE_HH 1
00041
00042 #include <cstddef>
00043
00050 struct G4ITType
00051 {
00052 private :
00053 friend G4ITType operator +(const G4ITType& left,const int& right);
00054 friend G4ITType operator -(const G4ITType& left,const int& right);
00055 int fValue;
00056
00057 public :
00058
00059 static size_t size();
00060
00061 G4ITType(const int d_ = 0) : fValue(d_) {;}
00062 G4ITType(const G4ITType & d_) : fValue(d_.fValue){;}
00063 G4ITType & operator=(const G4ITType & rhs);
00064 inline G4ITType & operator=(const int & rhs) { fValue = rhs; return *this;}
00065 inline operator int & () { return fValue; }
00066 inline operator const int & () const { return fValue; }
00067 inline bool operator==(const G4ITType & rhs) const { return fValue == rhs.fValue; }
00068 inline bool operator==(const int & rhs) const { return fValue == rhs; }
00069 inline bool operator<(const G4ITType & rhs) const { return fValue < rhs.fValue; }
00070 inline void operator++() { fValue++; }
00071 };
00072
00073 inline G4ITType operator +(const G4ITType& left,const int& right) {
00074 G4ITType output( left.fValue + right );
00075 return output;
00076 }
00077
00078 inline G4ITType operator -(const G4ITType& left,const int& right) {
00079 G4ITType output( left.fValue - right );
00080 return output;
00081 }
00082
00083 class G4ITTypeManager
00084 {
00085 private:
00086 static G4ITTypeManager* fgInstance ;
00087 G4ITType fLastType;
00088 G4ITTypeManager();
00089 virtual ~G4ITTypeManager();
00090
00091 public :
00092 G4ITType NewType() ;
00093 size_t size() const;
00094 static G4ITTypeManager* Instance();
00095 static void DeleteInstance();
00096 };
00097
00098 #define ITDef(T)\
00099 public:\
00100 static G4ITType fType;\
00101 static const G4ITType ITType()\
00102 {\
00103 return fType;\
00104 }\
00105 const G4ITType GetITType() const\
00106 {\
00107 return fType;\
00108 }\
00109 virtual G4bool equal(const G4IT &right) const \
00110 {\
00111 const T& right_mol = (const T&)right ;\
00112 return (this->operator==(right_mol));\
00113 }\
00114 virtual G4bool diff(const G4IT &right) const\
00115 {\
00116 const T& right_mol = (const T&)right ;\
00117 return (this->operator<(right_mol));\
00118 }
00119
00120 #define ITImp(T) \
00121 G4ITType T::fType = G4ITTypeManager::Instance()->NewType();
00122
00123 #endif // G4ITTYPE_HH