51 #ifndef INCLUDE_OKVIS_IMPLEMENTATION_TIME_HPP_
52 #define INCLUDE_OKVIS_IMPLEMENTATION_TIME_HPP_
68 #include <sys/timeb.h>
76 template<
class T,
class D>
78 sec = (int32_t)(t / 1000000000);
79 nsec = (int32_t)(t % 1000000000);
83 return *
static_cast<T*
>(
this);
86 template<
class T,
class D>
88 return D((int32_t) sec - (int32_t) rhs.sec,
89 (int32_t) nsec - (int32_t) rhs.nsec);
92 template<
class T,
class D>
94 return *
static_cast<const T*
>(
this) + (-rhs);
97 template<
class T,
class D>
99 int64_t sec_sum = (int64_t) sec + (int64_t) rhs.sec;
100 int64_t nsec_sum = (int64_t) nsec + (int64_t) rhs.nsec;
106 return T((uint32_t) sec_sum, (uint32_t) nsec_sum);
109 template<
class T,
class D>
112 return *
static_cast<T*
>(
this);
115 template<
class T,
class D>
118 return *
static_cast<T*
>(
this);
121 template<
class T,
class D>
123 return sec == rhs.sec && nsec == rhs.nsec;
126 template<
class T,
class D>
130 else if (sec == rhs.sec && nsec < rhs.nsec)
135 template<
class T,
class D>
139 else if (sec == rhs.sec && nsec > rhs.nsec)
144 template<
class T,
class D>
148 else if (sec == rhs.sec && nsec <= rhs.nsec)
153 template<
class T,
class D>
157 else if (sec == rhs.sec && nsec >= rhs.nsec)
164 #endif // INCLUDE_OKVIS_IMPLEMENTATION_TIME_HPP_
void normalizeSecNSecUnsigned(int64_t &sec, int64_t &nsec)
Definition: Time.cpp:391
void normalizeSecNSec(uint64_t &sec, uint64_t &nsec)
Definition: Time.cpp:370
T & fromNSec(uint64_t t)
Definition: Time.hpp:77
bool operator>=(const T &rhs) const
Definition: Time.hpp:154
T & operator+=(const D &rhs)
Definition: Time.hpp:110
bool operator<(const T &rhs) const
Definition: Time.hpp:127
bool operator==(const T &rhs) const
Definition: Time.hpp:122
bool operator<=(const T &rhs) const
Definition: Time.hpp:145
T operator+(const D &rhs) const
Definition: Time.hpp:98
D operator-(const T &rhs) const
Definition: Time.hpp:87
bool operator>(const T &rhs) const
Definition: Time.hpp:136
T & operator-=(const D &rhs)
Definition: Time.hpp:116