27 inline uint64_t as_nanoseconds(
const struct timespec& ts)
    29     return ts.tv_sec * 
static_cast<uint64_t
>(1000000000L) + ts.tv_nsec;
    31 inline void from_nanoseconds(
const uint64_t ns, 
struct timespec& ts)
    33     ts.tv_sec = (ns / 
static_cast<uint64_t
>(1000000000L));
    34     ts.tv_nsec = (ns % 
static_cast<uint64_t
>(1000000000L));
    50     GetSystemTimeAsFileTime(&t);
    51     return (((uint64_t)t.dwHighDateTime) << 32) | ((uint64_t)t.dwLowDateTime);
    53 #if defined(__APPLE__)    56     gettimeofday(&tv, 
nullptr);
    57     tim.tv_sec = tv.tv_sec;
    58     tim.tv_nsec = tv.tv_usec * 1000;
    64         case mrpt::Clock::Source::Realtime:
    67             clock_gettime(CLOCK_REALTIME, &tim);
    70         case mrpt::Clock::Source::Monotonic:
    78             clock_gettime(CLOCK_MONOTONIC, &tim);
    82             from_nanoseconds(
sum, tim);
    89     return uint64_t(tim.tv_sec) * UINT64_C(10000000) +
    90            UINT64_C(116444736) * UINT64_C(1000000000) + tim.tv_nsec / 100;
   102         uint64_t(t * 10000000.0) + UINT64_C(116444736) * UINT64_C(1000000000)));
   109                t.time_since_epoch().count() -
   110                UINT64_C(116444736) * UINT64_C(1000000000)) /
   117         s == mrpt::Clock::Source::Realtime ||
   118         s == mrpt::Clock::Source::Monotonic);
   127     timespec tim_rt{0, 0}, tim_mono{0, 0};
   128     clock_gettime(CLOCK_REALTIME, &tim_rt);
   129     clock_gettime(CLOCK_MONOTONIC, &tim_mono);
   137         std::cerr << 
"[mrpt::Clock::resetMonotonicToRealTimeEpoch] CRITICAL: "   138                      "Unreliable values: realtime_ns="   140                   << 
" should be larger than monotonic_ns="   147                                static_cast<int64_t>(old_diff))
 static double toDouble(const time_point t) noexcept
Converts a timestamp to a UNIX time_t-like number, with fractional part. 
 
std::chrono::duration< rep, period > duration
 
static time_point fromDouble(const double t) noexcept
Create a timestamp from its double representation. 
 
std::chrono::time_point< Clock > time_point
 
Source
Options for setting the source of all timestamps across MRPT: setActiveClock(), now() ...
 
static Source getActiveClock()
Returns the currently selected clock. 
 
static time_point now() noexcept
Returns the current time using the currently selected Clock source. 
 
#define ASSERT_(f)
Defines an assertion mechanism. 
 
static MonotonicToRealtimeEpoch m2r_epoch
 
CONTAINER::Scalar sum(const CONTAINER &v)
Computes the sum of all the elements. 
 
static bool monotonic_epoch_init
 
static void setActiveClock(const Source s)
Changes the selected clock to get time from when calling now(). 
 
static uint64_t getMonotonicToRealtimeOffset()
Returns the number of nanoseconds that are added to the output of the POSIX CLOCK_MONOTONIC to make t...
 
static mrpt::Clock::Source selectedClock
 
static int64_t resetMonotonicToRealTimeEpoch() noexcept
Monotonic clock might drift over time with respect to Realtime. 
 
static uint64_t getCurrentTime() noexcept