00001 // ===================================================================== 00031 // ===================================================================== 00032 #ifndef CLDAQ__TSYSTEMTIMER_HH 00033 #define CLDAQ__TSYSTEMTIMER_HH 00034 00035 #include "Tglobals.h" 00036 00037 00057 class TSystemTimer 00058 { 00059 00060 private: 00061 enum { tUndefined = -1, tIdle, tReady, tRunning }; 00062 00063 private: 00064 Tint theStatus; 00065 Tstring theUnit; 00066 Tdouble theBeginOfRealTime; 00067 Tdouble theEndOfRealTime; 00068 Tdouble theBeginOfSystemTime; 00069 Tdouble theEndOfSystemTime; 00070 Tdouble theBeginOfUserTime; 00071 Tdouble theEndOfUserTime; 00072 Tdouble thePausedTime; 00073 Tdouble theRunningTime; 00074 Tdouble theIdlingTime; 00075 TdoubleList theRealLapTime; 00076 TdoubleList theSystemLapTime; 00077 TdoubleList theUserLapTime; 00078 00079 public: 00080 TSystemTimer( const Tstring& theUnit = Tsec ); 00081 TSystemTimer( const TSystemTimer& right ); 00082 ~TSystemTimer(); 00083 00084 public: 00085 Tint GetStatus() const; 00086 Tdouble GetBeginOfRealTime() const; 00087 Tdouble GetEndOfRealTime() const; 00088 Tdouble GetBeginOfSystemTime() const; 00089 Tdouble GetEndOfSystemTime() const; 00090 Tdouble GetBeginOfUserTime() const; 00091 Tdouble GetEndOfUserTime() const; 00092 Tdouble GetPausedTime() const; 00093 Tdouble GetRunningTime() const; 00094 Tdouble GetIdlingTime() const; 00095 const TdoubleList& GetRealLapTime() const; 00096 const TdoubleList& GetSystemLapTime() const; 00097 const TdoubleList& GetUserLapTime() const; 00098 const Tstring& GetUnit() const; 00099 Tint GetNumberOfLaps() const; 00100 Tstring WhatTimeIsItNow() const; 00101 Tvoid SetUnit( const Tstring& unit ); 00102 00103 public: 00104 const TSystemTimer& operator=( const TSystemTimer& right ); 00105 friend Tostream& operator<<( Tostream& tos, const TSystemTimer& right ); 00106 00107 public: 00108 Tvoid Start(); 00109 Tvoid Pause(); 00110 Tvoid Stop(); 00111 Tvoid Lap(); 00112 Tvoid Restart(); 00113 00114 private: 00115 Tvoid initialize(); 00116 Tvoid clear(); 00117 Tvoid start(); 00118 Tvoid pause(); 00119 Tvoid stop(); 00120 Tvoid lap(); 00121 Tvoid restart(); 00122 Tvoid convertTimeScale( Tdouble factor ); 00123 00124 public: 00125 Tdouble GetRealElapsedTime(); 00126 Tdouble GetSystemElapsedTime(); 00127 Tdouble GetUserElapsedTime(); 00128 Tdouble GetTotalRunningTime(); 00129 Tdouble GetTotalIdlingTime(); 00130 00131 #ifdef __CLDAQ_ROOT_DLL 00132 ClassDef(TSystemTimer,0) 00133 #endif 00134 00135 }; 00136 00137 inline Tint TSystemTimer::GetStatus() const 00138 { 00139 return theStatus; 00140 } 00141 00142 inline Tdouble TSystemTimer::GetBeginOfRealTime() const 00143 { 00144 return theBeginOfRealTime; 00145 } 00146 00147 inline Tdouble TSystemTimer::GetEndOfRealTime() const 00148 { 00149 return theEndOfRealTime; 00150 } 00151 00152 inline Tdouble TSystemTimer::GetBeginOfSystemTime() const 00153 { 00154 return theBeginOfSystemTime; 00155 } 00156 00157 inline Tdouble TSystemTimer::GetEndOfSystemTime() const 00158 { 00159 return theEndOfSystemTime; 00160 } 00161 00162 inline Tdouble TSystemTimer::GetBeginOfUserTime() const 00163 { 00164 return theBeginOfUserTime; 00165 } 00166 00167 inline Tdouble TSystemTimer::GetEndOfUserTime() const 00168 { 00169 return theEndOfUserTime; 00170 } 00171 00172 inline Tdouble TSystemTimer::GetPausedTime() const 00173 { 00174 return thePausedTime; 00175 } 00176 00177 inline Tdouble TSystemTimer::GetRunningTime() const 00178 { 00179 return theRunningTime; 00180 } 00181 00182 inline Tdouble TSystemTimer::GetIdlingTime() const 00183 { 00184 return theIdlingTime; 00185 } 00186 00187 inline const TdoubleList& TSystemTimer::GetRealLapTime() const 00188 { 00189 return theRealLapTime; 00190 } 00191 00192 inline const TdoubleList& TSystemTimer::GetSystemLapTime() const 00193 { 00194 return theSystemLapTime; 00195 } 00196 00197 inline const TdoubleList& TSystemTimer::GetUserLapTime() const 00198 { 00199 return theUserLapTime; 00200 } 00201 00202 inline const Tstring& TSystemTimer::GetUnit() const 00203 { 00204 return theUnit; 00205 } 00206 00207 inline Tint TSystemTimer::GetNumberOfLaps() const 00208 { 00209 return (Tint)theRealLapTime.size(); 00210 } 00211 00212 #endif