DRDE/ACTK1_0/session/Timer.hpp

52 lines
1.2 KiB
C++
Raw Normal View History

#ifndef __TIMER_HPP
#define __TIMER_HPP
#include "common/ParameterSyntaxException.hpp"
#include <time.h>
2014-01-15 00:52:58 +00:00
#ifdef __MACH__
#include <mach/clock.h>
#include <mach/mach.h>
#endif
class Timer
{
public:
/// milliseconds since epoch.
static long long now();
/// argument and result is milliseconds.
static long long msDiff(long long compareTime);
/// Once called, future calls to now() will return this
/// date until setTime(...) is called again with an empty string.
static void setTime(const std::string& dateString) throw (ParameterSyntaxException);
/**
* Give the value, in struct timespec representation, of the time
* represented by the given offset (in milliseconds) in the future from
* the current time as understood by the Timer.
*
* @param msOffset the number of milliseconds in the future to give a
* time for.
*/
static struct timespec msOffset2abs(long long msOffset);
private:
2014-01-15 00:52:58 +00:00
#ifndef OSX_10_8
static clockid_t getClock();
2014-01-14 22:27:23 +00:00
#else
static clock_t getClock();
#endif
static bool useRealTime;
// milliseconds.
static long long fixedTime;
};
#endif // __TIMER_HPP