50 #ifndef INCLUDE_OKVIS_TIME_HPP_
51 #define INCLUDE_OKVIS_TIME_HPP_
60 #pragma warning(disable: 4244)
61 #pragma warning(disable: 4661)
84 #include <sys/timeb.h>
104 : std::runtime_error(
"This windows platform does not "
105 "support the high-performance timing api.") {
125 template<
class T,
class D>
151 return !(*
static_cast<const T*
>(
this) == rhs);
159 return (
double)
sec + 1e-9 * (double)
nsec;
163 sec = (uint32_t) floor(t);
164 nsec = (uint32_t) std::round((t -
sec) * 1e9);
165 return *
static_cast<T*
>(
this);
169 return (uint64_t)
sec * 1000000000ull + (uint64_t)
nsec;
193 Time(uint32_t _sec, uint32_t _nsec)
268 std::ostream &
operator <<(std::ostream &os,
const Time &rhs);
269 std::ostream &
operator <<(std::ostream &os,
const WallTime &rhs);
273 #endif // INCLUDE_OKVIS_TIME_HPP_
WallTime(double t)
Definition: Time.hpp:249
bool is_zero() const
Definition: Time.hpp:176
Time representation. Always wall-clock time.
Definition: Time.hpp:239
void normalizeSecNSecUnsigned(int64_t &sec, int64_t &nsec)
Definition: Time.cpp:391
TimeBase()
Definition: Time.hpp:130
static void init()
Definition: Time.cpp:249
static Time now()
Retrieve the current time. Returns the current wall clock time.
Definition: Time.cpp:237
static bool isSimTime()
Definition: Time.cpp:229
void normalizeSecNSec(uint64_t &sec, uint64_t &nsec)
Definition: Time.cpp:370
uint32_t sec
Definition: Time.hpp:128
T & fromNSec(uint64_t t)
Definition: Time.hpp:77
bool isZero() const
Definition: Time.hpp:173
Base class for Time implementations. Provides storage, common functions and operator overloads...
Definition: Time.hpp:126
Header file for the DurationBase, Duration and WallDuration class.
static bool isSystemTime()
Definition: Time.hpp:263
std::ostream & operator<<(std::ostream &os, const Duration &rhs)
Definition: Time.cpp:284
Time()
Definition: Time.hpp:189
Time(uint32_t _sec, uint32_t _nsec)
Definition: Time.hpp:193
bool operator>=(const T &rhs) const
Definition: Time.hpp:154
static bool waitForValid()
Wait for time to become valid.
Definition: Time.cpp:259
T & operator+=(const D &rhs)
Definition: Time.hpp:110
static void setNow(const Time &new_now)
Definition: Time.cpp:245
uint64_t toNSec() const
Definition: Time.hpp:168
Time(double t)
Definition: Time.hpp:197
bool operator<(const T &rhs) const
Definition: Time.hpp:127
T & fromSec(double t)
Definition: Time.hpp:162
bool operator==(const T &rhs) const
Definition: Time.hpp:122
bool operator<=(const T &rhs) const
Definition: Time.hpp:145
Duration representation for use with the Time class.
Definition: Duration.hpp:131
static bool useSystemTime()
Definition: Time.cpp:225
~TimeBase()
Definition: Time.hpp:142
Duration representation for use with the WallTime class.
Definition: Duration.hpp:159
static bool isValid()
Returns whether or not the current time is valid. Time is valid if it is non-zero.
Definition: Time.cpp:255
WallTime(uint32_t _sec, uint32_t _nsec)
Definition: Time.hpp:245
T operator+(const D &rhs) const
Definition: Time.hpp:98
Time representation. May either represent wall clock time or ROS clock time.
Definition: Time.hpp:187
bool operator!=(const T &rhs) const
Definition: Time.hpp:150
TimeBase(uint32_t _sec, uint32_t _nsec)
Definition: Time.hpp:134
static WallTime now()
Returns the current wall clock time.
Definition: Time.cpp:354
uint32_t nsec
Definition: Time.hpp:128
WallTime()
Definition: Time.hpp:241
static bool isSystemTime()
Definition: Time.cpp:233
static bool sleepUntil(const Time &end)
Sleep until a specific time has been reached.
Definition: Time.cpp:289
D operator-(const T &rhs) const
Definition: Time.hpp:87
bool operator>(const T &rhs) const
Definition: Time.hpp:136
TimeBase(double t)
Definition: Time.hpp:139
static void shutdown()
Definition: Time.cpp:252
T & operator-=(const D &rhs)
Definition: Time.hpp:116
double toSec() const
Definition: Time.hpp:158
static bool sleepUntil(const WallTime &end)
Sleep until a specific time has been reached.
Definition: Time.cpp:310