Time.h
Go to the documentation of this file.
00001 // -*- C++ -*-
00019 #ifndef COIL_TIME_H
00020 #define COIL_TIME_H
00021 
00022 #include <coil/config_coil.h>
00023 #include <coil/TimeValue.h>
00024 #if defined (WIN32)
00025 #pragma warning( disable : 4244 ) 
00026 #pragma warning( disable : 4312 ) 
00027 #endif
00028 #include <ace/OS_NS_sys_time.h>
00029 #include <ace/OS_NS_unistd.h>
00030 #include <ace/OS_NS_sys_select.h>
00031 #if defined (WIN32)
00032 #pragma warning( default : 4244 ) 
00033 #pragma warning( default : 4312 ) 
00034 #endif
00035 #include <coil/TimeValue.h>
00036 
00037 namespace coil
00038 {
00039 
00040   inline unsigned int sleep(unsigned int seconds)
00041   {
00042     return ACE_OS::sleep(seconds);
00043   }
00044 
00045   inline int sleep(TimeValue& interval)
00046   {
00047     ACE_Time_Value tv(interval.sec(), interval.usec());
00048     return ACE_OS::select(0, 0, 0, 0, &tv);
00049   }
00050 
00051   inline int usleep(useconds_t usec)
00052   {
00053     ACE_Time_Value tv(0, usec);
00054     return ACE_OS::select(0, 0, 0, 0, &tv);
00055   }
00056 
00057   inline int gettimeofday(struct timeval *tv, struct timezone *tz)
00058   {
00059     ACE_Time_Value atv(ACE_OS::gettimeofday());
00060     if (tv != NULL)
00061       {
00062         tv->tv_sec  = static_cast<long int>(atv.sec());
00063         tv->tv_usec = static_cast<long int>(atv.usec());
00064       }
00065     return 0;
00066   }
00067 
00068   inline TimeValue gettimeofday()
00069   {
00070     ACE_Time_Value atv(ACE_OS::gettimeofday());
00071     return TimeValue(static_cast<long int>(atv.sec()),
00072                      static_cast<long int>(atv.usec()));
00073   }
00074 
00075   inline int settimeofday(const struct timeval *tv , const struct timezone *tz)
00076   {
00077     return 0; // no implementation
00078   }
00079 
00080 
00081 };
00082 
00083 #endif // COIL_TIME_H


openrtm_aist
Author(s): Noriaki Ando
autogenerated on Thu Aug 27 2015 14:16:39