ace/coil/Time.h
Go to the documentation of this file.
1 // -*- C++ -*-
19 #ifndef COIL_TIME_H
20 #define COIL_TIME_H
21 
22 #include <coil/config_coil.h>
23 #include <coil/TimeValue.h>
24 #if defined (WIN32)
25 #pragma warning( disable : 4244 )
26 #pragma warning( disable : 4312 )
27 #endif
28 #include <ace/OS_NS_sys_time.h>
29 #include <ace/OS_NS_unistd.h>
30 #include <ace/OS_NS_sys_select.h>
31 #if defined (WIN32)
32 #pragma warning( default : 4244 )
33 #pragma warning( default : 4312 )
34 #endif
35 #include <coil/TimeValue.h>
36 
37 namespace coil
38 {
39 
40  inline unsigned int sleep(unsigned int seconds)
41  {
42  return ACE_OS::sleep(seconds);
43  }
44 
45  inline int sleep(TimeValue& interval)
46  {
47  ACE_Time_Value tv(interval.sec(), interval.usec());
48  return ACE_OS::select(0, 0, 0, 0, &tv);
49  }
50 
51  inline int usleep(useconds_t usec)
52  {
53  ACE_Time_Value tv(0, usec);
54  return ACE_OS::select(0, 0, 0, 0, &tv);
55  }
56 
57  inline int gettimeofday(struct timeval *tv, struct timezone *tz)
58  {
59  ACE_Time_Value atv(ACE_OS::gettimeofday());
60  if (tv != NULL)
61  {
62  tv->tv_sec = static_cast<long int>(atv.sec());
63  tv->tv_usec = static_cast<long int>(atv.usec());
64  }
65  return 0;
66  }
67 
69  {
70  ACE_Time_Value atv(ACE_OS::gettimeofday());
71  return TimeValue(static_cast<long int>(atv.sec()),
72  static_cast<long int>(atv.usec()));
73  }
74 
75  inline int settimeofday(const struct timeval *tv , const struct timezone *tz)
76  {
77  return 0; // no implementation
78  }
79 
80 
81 };
82 
83 #endif // COIL_TIME_H
long int sec() const
Get value of second time scale.
Definition: TimeValue.h:110
unsigned int sleep(unsigned int seconds)
Stop a processing at specified second time.
Definition: ace/coil/Time.h:40
int sleep(TimeValue &interval)
Definition: ace/coil/Time.h:45
int gettimeofday(struct timeval *tv, struct timezone *tz)
Get the time and timezone.
Definition: ace/coil/Time.h:57
int settimeofday(const struct timeval *tv, const struct timezone *tz)
Set the time and timezone.
Definition: ace/coil/Time.h:75
long int usec() const
Get value of micro second time scale.
Definition: TimeValue.h:131
TimeValue gettimeofday()
Get the time.
Definition: ace/coil/Time.h:68
int usleep(useconds_t usec)
Stop a processing at specified micro second time.
Definition: ace/coil/Time.h:51
Common Object Interface Layer.


openrtm_aist
Author(s): Noriaki Ando
autogenerated on Thu Jun 6 2019 19:26:00