Fawkes API
Fawkes Development Version
|
24 #ifndef _UTILS_TIME_TIME_H_
25 #define _UTILS_TIME_TIME_H_
44 double res = a.tv_sec - b.tv_sec + (a.tv_usec - b.tv_usec) / 1000000.0;
59 const long int a_usec,
61 const long int b_usec)
64 double res = a_sec - b_sec + (a_usec - b_usec) / 1000000.0;
75 return (
long)round(sec * 1000000.);
87 return (a.tv_sec - b.tv_sec) * 1000000 + (a.tv_usec - b.tv_usec);
99 Time(
long sec,
long usec,
Clock *clock = 0);
124 return time_.tv_usec / 1000;
129 return time_.tv_usec;
134 return time_.tv_usec * 1000;
140 usec = time_.tv_usec;
145 return (time_.tv_sec == 0) && (time_.tv_usec == 0);
157 void add(
double seconds);
193 const char *
str(
bool utc =
false)
const;
194 void str_r(
char *s,
bool utc =
false);
201 mutable char *timestr_;
long in_msec() const
Convert the stored time into milli-seconds.
void set_time(const timeval *tv)
Sets the time.
const char * str(bool utc=false) const
Output function.
const Time TIME_MIN
Instance of Time denoting the minimum value possible.
long in_usec() const
Convert the stored time into micro-seconds.
bool operator<(const Time &t) const
Less than operator.
Time & operator+=(const long int usec)
+= operator
const Time TIME_MAX
Instance of Time denoting the maximum value possible.
const timeval * get_timeval() const
Time & stamp_systime()
Set this time to the current system time.
long int time_diff_usec(const timeval &a, const timeval &b)
Get difference between two time structs in microseconds.
double time_diff_sec(const timeval &a, const timeval &b)
Calculate time difference of two time structs.
void str_r(char *s, bool utc=false)
Output function.
void wait()
Wait (sleep) for this time.
bool operator>(const Time &t) const
Greater than operator.
bool operator<=(const Time &t) const
Less than or equal to operator.
void wait_systime()
Wait (sleep) for this system time.
void set_clock(Clock *clock)
Set clock for this instance.
void add(double seconds)
Add seconds.
Time & operator-=(const Time &t)
-= operator.
long int time_sec_to_usec(double sec)
Convert seconds to micro seconds.
Time operator+(const double sec) const
Operator that adds times.
Time & stamp()
Set this time to the current time.
bool operator>=(const Time &t) const
Greater than or equal to operator.
Time operator-(const Time &t) const
Operator that substracts one Time from another.
void get_timestamp(long &sec, long &usec) const
static const unsigned int TIMESTR_SIZE
Maximum size of string returned by str() and the minimum size of the string passwd to str_r().
double in_sec() const
Convet time to seconds.
Time & operator=(const Time &t)
Assign operator.
bool operator==(const Time &t) const
Check equality of times.
bool operator!=(const Time &t) const
Check inequality of times.