TimeService.hpp
00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #ifndef HEART_BEAT_GENERATOR_HPP
00022 #define HEART_BEAT_GENERATOR_HPP
00023
00024 #include "Time.hpp"
00025 #include "rtt-config.h"
00026
00027 namespace RTT
00028 {
00029
00034 class RTT_API TimeService
00035 {
00036 public:
00040 typedef double Seconds;
00041
00045 typedef long secs;
00046
00050 typedef long msecs;
00051
00055 typedef long usecs;
00056
00060 typedef long long nsecs;
00061
00065 typedef long long ticks;
00066
00067 public:
00068 static TimeService* Instance();
00069
00076 static bool Release();
00077
00081 virtual ~TimeService();
00082
00089 ticks ticksGet() const { return getTicks(); }
00090
00096 ticks getTicks() const;
00097
00105 ticks ticksGet( ticks &relativeTime ) const { return getTicks( relativeTime ); }
00106
00113 ticks getTicks( ticks &relativeTime ) const;
00114
00121 ticks ticksSince( ticks relativeTime ) const;
00122
00132 Seconds secondsGet( ticks &relativeTime ) const { return getSeconds(relativeTime); }
00133
00142 Seconds getSeconds( ticks &relativeTime ) const;
00143
00150 Seconds secondsSince( ticks relativeTime ) const;
00151
00156 Seconds secondsChange( Seconds delta );
00157
00163 void enableSystemClock( bool yes_no );
00164
00170 nsecs getNSecs() const;
00171
00178 nsecs getNSecs( nsecs &relativeTime ) const;
00179
00185 static ticks nsecs2ticks( const nsecs m );
00186
00190 static nsecs ticks2nsecs( const ticks t );
00191
00195 static const ticks InfiniteTicks;
00196
00200 static const nsecs InfiniteNSecs;
00201
00205 static const Seconds InfiniteSeconds;
00206 protected:
00207
00211 TimeService();
00212
00213 private:
00214
00218 static TimeService* _instance;
00219
00223 ticks offset;
00224
00225 bool use_clock;
00226 };
00227 }
00228
00229 #endif