TimeService.hpp

00001 /***************************************************************************
00002  tag: Peter Soetens  Wed Apr 17 16:01:36 CEST 2002  TimeService.h
00003 
00004                        TimeService.h -  description
00005                           -------------------
00006    begin                : Wed April 17 2002
00007    copyright            : (C) 2002 Peter Soetens
00008    email                : peter.soetens@mech.kuleuven.ac.be
00009 
00010 ***************************************************************************
00011 *                                                                         *
00012 *   This program is free software; you can redistribute it and/or modify  *
00013 *   it under the terms of the GNU General Public License as published by  *
00014 *   the Free Software Foundation; either version 2 of the License, or     *
00015 *   (at your option) any later version.                                   *
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 } // namespace RTT
00228 
00229 #endif
Generated on Thu Dec 23 13:22:38 2010 for Orocos Real-Time Toolkit by  doxygen 1.6.3