00001 #ifndef FCAM_TIME_H
00002 #define FCAM_TIME_H
00003
00006
00007 #include <time.h>
00008 #include <sys/time.h>
00009
00010 namespace FCam {
00011
00019 class Time {
00020 public:
00021
00023 static Time now();
00024
00026 Time(timeval t_) : t(t_) {};
00027
00029 Time(struct timespec t_) {
00030 t.tv_sec = t_.tv_sec;
00031 t.tv_usec = t_.tv_nsec/1000;
00032 }
00033
00034 Time() {}
00035
00037 int s() const {return t.tv_sec;}
00038
00040 int us() const {return t.tv_usec;}
00041
00049 Time operator+(int usecs) const;
00050 Time operator+=(int usecs);
00051 Time operator-(int usecs) const {return (*this) + (-usecs);}
00052 Time operator-=(int usecs) {return (*this) += (-usecs);}
00053 int operator-(const Time &other) const;
00055
00061 bool operator<(const Time &other) const;
00062 bool operator>(const Time &other) const;
00063 bool operator>=(const Time &other) const;
00064 bool operator<=(const Time &other) const;
00065 bool operator==(const Time &other) const;
00066 bool operator!=(const Time &other) const;
00068
00075 operator timeval();
00076 operator struct timespec();
00078
00079 private:
00080 timeval t;
00081 };
00082
00083 }
00084
00085 #endif