1 #ifndef __UMicroseconds_h__
2 #define __UMicroseconds_h__
5 #include "UMicroseconds.h"
10 #include "BasicTypes/WUDefines.h"
11 #include "BasicTypes/WUTypes.h"
14 // a wraper for Microseconds function from Timer.h
15 class DllExport UMicroseconds
20 typedef int64_t TimeKeeper;
23 typedef uint64_t TimeKeeper;
26 typedef uint64_t TimeKeeper;
39 UMicroseconds(const TimeKeeper in_initVal) : theTime(in_initVal) {}
41 UMicroseconds(const UMicroseconds& inUM) : theTime(inUM.theTime) {}
42 UMicroseconds& operator=(const UMicroseconds& inUM) {theTime = inUM.theTime; return *this;}
43 UMicroseconds& operator+=(const TimeKeeper in_timeToAdd) {theTime += in_timeToAdd; return *this;}
45 UMicroseconds& ReadTime();
47 TimeKeeper GetNativeTime() const {return theTime;}
48 operator uint64_t () {return static_cast<uint64_t>(theTime);}
49 operator double () const {return static_cast<const double>(theTime);}
51 double Seconds() const {return static_cast<double>(theTime) / double(1000000);}
52 double MilliSeconds() const {return static_cast<double>(theTime) / double(1000);}
53 double MicroSeconds() const {return static_cast<double>(theTime);}
61 inline UMicroseconds operator-(const UMicroseconds& in_one, const UMicroseconds& in_two)
63 UMicroseconds retVal(in_one.GetNativeTime() - in_two.GetNativeTime());
67 class UMicrosecondsAccumulator
70 UMicrosecondsAccumulator() : m_start_time(0), m_accumulator(0) {}
76 UMicroseconds GetAccumulatedTime() const;
78 UMicrosecondsAccumulator& operator+=(const UMicrosecondsAccumulator&);
81 UMicroseconds m_start_time;
82 UMicroseconds m_accumulator;
85 inline UMicroseconds operator-(const UMicrosecondsAccumulator& in_one, const UMicrosecondsAccumulator& in_two)
87 UMicroseconds retVal(in_one.GetAccumulatedTime() - in_two.GetAccumulatedTime());
91 //=========================================================================================//
92 inline void MicrosecondDelay(double amt)
93 //=========================================================================================//
101 } while ((now.MicroSeconds() - than.MicroSeconds()) < amt);
104 } // namespace wvNS {
105 #endif //#ifndef __UMicroseconds_h__