YARP
Yet Another Robot Platform
PlatformTime.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2006-2020 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/High_Res_Timer.h>
16 # include <ace/OS_NS_sys_time.h>
17 # include <ace/Time_Value.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 } // namespace impl
47 } // namespace os
48 } // namespace yarp
49 
50 #endif // YARP_OS_IMPL_PLATFORMTIME_H
yarp::os::impl::getTime
void getTime(YARP_timeval &now)
Definition: PlatformTime.cpp:18
yarp::os::Time::now
double now()
Return the current time in seconds, relative to an arbitrary starting point.
Definition: Time.cpp:124
yarp::os::impl::subtractTime
void subtractTime(YARP_timeval &val, const YARP_timeval &subtract)
Definition: PlatformTime.cpp:62
yarp::os::impl::fromDouble
void fromDouble(YARP_timeval &v, double x, int unit=1)
Definition: PlatformTime.cpp:88
system.h
yarp::os::impl::addTime
void addTime(YARP_timeval &val, const YARP_timeval &add)
Definition: PlatformTime.cpp:47
yarp::os::impl::toDouble
double toDouble(const YARP_timeval &v)
Definition: PlatformTime.cpp:79
yarp::os::impl::YARP_timeval
struct timeval YARP_timeval
Definition: PlatformTime.h:35
yarp
The main, catch-all namespace for YARP.
Definition: environment.h:18
yarp::os::impl::sleepThread
void sleepThread(YARP_timeval &sleep_period)
Definition: PlatformTime.cpp:38