YARP
Yet Another Robot Platform
Time.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2006-2018 Istituto Italiano di Tecnologia (IIT)
3  * Copyright (C) 2006-2010 RobotCub Consortium
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_TIME_H
11 #define YARP_OS_TIME_H
12 
13 #include <yarp/os/Clock.h>
14 #include <yarp/os/SystemClock.h>
15 #include <yarp/os/NetworkClock.h>
16 
17 #include <string>
18 
19 namespace yarp {
20 namespace os {
21 
22 enum class ShouldUseSystemClock { No = 0, Yes = 1 };
23 
25 {
31 };
32 
33 /*
34  * Services related to time -- delay, current time.
35  */
36 namespace Time {
37 
42 YARP_OS_API void delay(double seconds);
43 
49 YARP_OS_API double now();
50 
55 YARP_OS_API void yield();
56 
60 YARP_OS_API void useSystemClock();
61 
77 YARP_OS_API void useNetworkClock(const std::string& clock, std::string localPortName="");
78 
89 YARP_OS_API void useCustomClock(Clock *clock);
90 
94 YARP_OS_API bool isSystemClock();
95 
99 YARP_OS_API bool isNetworkClock();
100 
104 YARP_OS_API bool isCustomClock();
105 
109 YARP_OS_API yarpClockType getClockType();
110 
115 YARP_OS_API std::string clockTypeToString(yarpClockType type);
116 
122 YARP_OS_API bool isValid();
123 
124 #ifndef YARP_NO_DEPRECATED // Since YARP 3.0.0
125 
134 YARP_DEPRECATED
135 YARP_OS_API void turboBoost();
136 #endif
137 
138 } // namespace Time
139 } // namespace os
140 } // namespace yarp
141 
142 #endif // YARP_OS_TIME_H
bool isNetworkClock()
Check if YARP is providing network time.
Definition: Time.cpp:279
void useSystemClock()
Configure YARP to use system time (this is the default).
Definition: Time.cpp:143
ShouldUseSystemClock
Definition: Time.h:22
The main, catch-all namespace for YARP.
bool isCustomClock()
Check if YARP is using a user-defined custom time.
Definition: Time.cpp:283
void yield()
The calling thread releases its remaining quantum upon calling this function.
Definition: Time.cpp:138
double now()
Return the current time in seconds, relative to an arbitrary starting point.
Definition: Time.cpp:123
void useNetworkClock(const std::string &clock, std::string localPortName="")
Configure YARP to read time from a specified topic.
Definition: Time.cpp:186
void turboBoost()
For OS where it makes sense sets the scheduler to be called more often.
Definition: Time.cpp:132
yarpClockType
Definition: Time.h:24
yarpClockType getClockType()
Definition: Time.cpp:287
std::string clockTypeToString(yarpClockType type)
Converts clock type enum into string.
Definition: Time.cpp:292
void delay(double seconds)
Wait for a certain number of seconds.
Definition: Time.cpp:115
void useCustomClock(Clock *clock)
Configure YARP clients to use a custom clock source provided by the user.
Definition: Time.cpp:238
bool isSystemClock()
Check if YARP is providing system time.
Definition: Time.cpp:266
bool isValid()
Check if time is valid (non-zero).
Definition: Time.cpp:324