MRPT  1.9.9
Clock.cpp
Go to the documentation of this file.
1 /* +------------------------------------------------------------------------+
2  | Mobile Robot Programming Toolkit (MRPT) |
3  | http://www.mrpt.org/ |
4  | |
5  | Copyright (c) 2005-2018, Individual contributors, see AUTHORS file |
6  | See: http://www.mrpt.org/Authors - All rights reserved. |
7  | Released under BSD License. See details in http://www.mrpt.org/License |
8  +------------------------------------------------------------------------+ */
9 
10 #include "core-precomp.h" // Precompiled headers
11 
12 #include <mrpt/core/Clock.h>
13 
14 #ifdef _WIN32
15 #include <windows.h>
16 #else
17 #include <sys/time.h> // timeval
18 #endif
19 
20 #include <ctime> // clock_gettime
21 
23 {
24 #ifdef _WIN32
25  FILETIME t;
26  GetSystemTimeAsFileTime(&t);
27  return (((uint64_t)t.dwHighDateTime) << 32) | ((uint64_t)t.dwLowDateTime);
28 #else
29 #if defined(__APPLE__)
30  struct timeval tv;
31  timespec tim;
32  gettimeofday(&tv, nullptr);
33  tim.tv_sec = tv.tv_sec;
34  tim.tv_nsec = tv.tv_usec * 1000;
35 #else
36  timespec tim;
37  clock_gettime(CLOCK_REALTIME, &tim);
38 #endif
39 
40  // Convert to TTimeStamp 100-nanoseconds representation:
41  return uint64_t(tim.tv_sec) * UINT64_C(10000000) +
42  UINT64_C(116444736) * UINT64_C(1000000000) + tim.tv_nsec / 100;
43 #endif
44 }
45 
47 {
49 }
50 
52 {
54  uint64_t(t * 10000000.0) + UINT64_C(116444736) * UINT64_C(1000000000)));
55 }
56 
std::chrono::duration< rep, period > duration
Definition: Clock.h:25
GLdouble GLdouble t
Definition: glext.h:3689
static time_point fromDouble(const double t) noexcept
Create a timestamp from its double representation.
Definition: Clock.cpp:51
std::chrono::time_point< Clock > time_point
Definition: Clock.h:26
static time_point now() noexcept
Returns the current time, with the highest resolution available.
Definition: Clock.cpp:46
static uint64_t getCurrentTime()
Definition: Clock.cpp:22
unsigned __int64 uint64_t
Definition: rptypes.h:50



Page generated by Doxygen 1.8.14 for MRPT 1.9.9 Git: 7d5e6d718 Fri Aug 24 01:51:28 2018 +0200 at lun nov 2 08:35:50 CET 2020