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