YARP
Yet Another Robot Platform
PlatformTime.h
Go to the documentation of this file.
1 /*
2  * SPDX-FileCopyrightText: 2006-2021 Istituto Italiano di Tecnologia (IIT)
3  * SPDX-FileCopyrightText: 2011 Anne van Rossum <anne@almende.com>
4  * SPDX-License-Identifier: BSD-3-Clause
5  */
6 
7 #ifndef YARP_OS_IMPL_PLATFORMTIME_H
8 #define YARP_OS_IMPL_PLATFORMTIME_H
9 
10 #include <yarp/conf/system.h>
11 #ifdef YARP_HAS_ACE
12 # include <ace/High_Res_Timer.h>
13 # include <ace/OS_NS_sys_time.h>
14 # include <ace/Time_Value.h>
15 // In one the ACE headers there is a definition of "main" for WIN32
16 # ifdef main
17 # undef main
18 # endif
19 # define PLATFORM_TIME_SET(x, y) x.set(y)
20 #else
21 # include <sys/time.h>
22 # define PLATFORM_TIME_SET(x, y) fromDouble(x, y)
23 #endif
24 
25 namespace yarp {
26 namespace os {
27 namespace impl {
28 
29 #ifdef YARP_HAS_ACE
30 typedef ACE_Time_Value YARP_timeval;
31 #else
32 typedef struct timeval YARP_timeval;
33 #endif
34 
35 void getTime(YARP_timeval& now);
36 void sleepThread(YARP_timeval& sleep_period);
37 void addTime(YARP_timeval& val, const YARP_timeval& add);
38 void subtractTime(YARP_timeval& val,
39  const YARP_timeval& subtract);
40 double toDouble(const YARP_timeval& v);
41 void fromDouble(YARP_timeval& v, double x, int unit = 1);
42 
43 } // namespace impl
44 } // namespace os
45 } // namespace yarp
46 
47 #endif // YARP_OS_IMPL_PLATFORMTIME_H
double now()
Return the current time in seconds, relative to an arbitrary starting point.
Definition: Time.cpp:121
void addTime(YARP_timeval &val, const YARP_timeval &add)
void getTime(YARP_timeval &now)
double toDouble(const YARP_timeval &v)
struct timeval YARP_timeval
Definition: PlatformTime.h:32
void subtractTime(YARP_timeval &val, const YARP_timeval &subtract)
void sleepThread(YARP_timeval &sleep_period)
void fromDouble(YARP_timeval &v, double x, int unit=1)
The main, catch-all namespace for YARP.
Definition: dirs.h:16