00001 00033 #ifndef ABA_TIMER_H 00034 #define ABA_TIMER_H 00035 #include <iostream> 00036 using namespace std; 00037 00038 #include "abacus/abacusroot.h" 00039 00040 #ifdef ABACUS_PARALLEL 00041 #include <ace/Synch.h> 00042 #endif 00043 00044 class ABA_STRING; 00045 class ABA_GLOBAL; 00046 00047 class ABA_TIMER : public ABA_ABACUSROOT { 00048 public: 00049 00056 ABA_TIMER(ABA_GLOBAL *glob); 00057 00064 ABA_TIMER(ABA_GLOBAL *glob, long centiSeconds); 00065 00067 virtual ~ABA_TIMER(); 00068 00082 friend ostream& operator<<(ostream& out, const ABA_TIMER& rhs); 00083 00090 void start(bool reset = false); 00091 00097 void stop(); 00098 00101 void reset(); 00102 00106 bool running() const; 00107 00112 long centiSeconds() const; 00113 00118 long seconds() const; 00119 00124 long minutes() const; 00125 00130 long hours() const; 00131 00142 bool exceeds(const ABA_STRING &maxTime) const; 00143 00146 void addCentiSeconds(long centiSeconds); 00147 00148 protected: 00149 00172 virtual long theTime() const = 0; 00173 00176 ABA_GLOBAL *glob_; 00177 00178 private: 00179 00182 long startTime_; 00183 00186 long totalTime_; 00187 00190 bool running_; 00191 #ifdef ABACUS_PARALLEL 00192 ACE_Thread_Mutex mutex_; 00193 #endif 00194 }; 00195 00196 #endif // ABA_TIMER_H 00197 00198