00001
00002
00003
00004
00005 #ifndef BALL_CONCEPT_TIMESTAMP_H
00006 #define BALL_CONCEPT_TIMESTAMP_H
00007
00008 #ifndef BALL_CONFIG_CONFIG_H
00009 # include <BALL/CONFIG/config.h>
00010 #endif
00011
00012 #ifndef BALL_COMMON_CREATE_H
00013 # include <BALL/COMMON/create.h>
00014 #endif
00015
00016 #ifndef BALL_COMMON_DEBUG_H
00017 # include <BALL/COMMON/debug.h>
00018 #endif
00019
00020 #ifndef BALL_CONCEPT_PERSISTENCEMANAGER_H
00021 # include <BALL/CONCEPT/persistenceManager.h>
00022 #endif
00023
00024 #include <iostream>
00025
00026 namespace BALL
00027 {
00028
00037 class BALL_EXPORT PreciseTime
00038 {
00039
00040 public:
00041
00042 BALL_CREATE(PreciseTime)
00043
00044
00047
00051 PreciseTime();
00052
00055 PreciseTime(const PreciseTime& time);
00056
00059 PreciseTime(long secs, long usecs);
00060
00063 virtual ~PreciseTime();
00064
00066
00069
00072 static const PreciseTime ZERO;
00073
00075
00078
00081 void set(long secs, long usecs);
00082
00085 void set(const PreciseTime& time);
00086
00089 const PreciseTime& operator = (const PreciseTime& time);
00090
00093 virtual void clear()
00094 ;
00095
00097
00100
00103 bool operator < (const PreciseTime& time) const;
00104
00107 bool operator > (const PreciseTime& time) const;
00108
00111 bool operator == (const PreciseTime& time) const;
00112
00114
00117
00120 long getSeconds() const;
00121
00124 long getMicroSeconds() const;
00125
00129 static PreciseTime now();
00130
00132
00136
00143 void write(PersistenceManager& pm) const;
00144
00151 bool read(PersistenceManager& pm);
00152
00154
00155 protected:
00156
00157 long secs_;
00158 long usecs_;
00159
00160 #ifdef BALL_HAS_WINDOWS_PERFORMANCE_COUNTER
00161 static long ticks_;
00162 #endif
00163 };
00164
00171 class BALL_EXPORT TimeStamp
00172 {
00173 public:
00174
00175 BALL_CREATE(TimeStamp)
00176
00177
00180
00183 TimeStamp();
00184
00187 virtual ~TimeStamp();
00188
00190
00193
00196 bool isNewerThan(const PreciseTime& time) const;
00197
00200 bool isOlderThan(const PreciseTime& time) const;
00201
00204 bool isNewerThan(const TimeStamp& stamp) const;
00205
00208 bool isOlderThan(const TimeStamp& stamp) const;
00209
00212 bool operator == (const TimeStamp& stamp) const;
00213
00215
00218
00225 virtual void stamp(const PreciseTime& time = PreciseTime::ZERO);
00226
00230 const PreciseTime& getTime() const;
00231
00233
00236
00239 const PreciseTime& operator = (const PreciseTime& time);
00240
00243 virtual void clear();
00244
00246
00249
00256 void write(PersistenceManager& pm) const;
00257
00264 bool read(PersistenceManager& pm);
00265
00267
00268 protected:
00269
00272 PreciseTime time_;
00273 };
00274
00278
00281 BALL_EXPORT
00282 std::ostream& operator << (std::ostream& os, const PreciseTime& time);
00283
00286 BALL_EXPORT
00287 std::ostream& operator << (std::ostream& os, const TimeStamp& stamp);
00288
00290
00291
00292 # ifndef BALL_NO_INLINE_FUNCTIONS
00293 # include <BALL/CONCEPT/timeStamp.iC>
00294 # endif
00295
00296 }
00297
00298 #endif // BALL_CONCEPT_TIMESTAMP_H