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 
00026 namespace RTT
00027 {
00028 
00033     class TimeService
00034     {
00035     public:
00039         typedef double Seconds;
00040 
00044         typedef long secs;
00045 
00049         typedef long msecs;
00050 
00054         typedef long usecs;
00055 
00059         typedef long long nsecs;
00060 
00064         typedef long long ticks;
00065 
00066     public:
00067         static TimeService* Instance();
00068 
00075         static bool Release();
00076 
00080         virtual ~TimeService();
00081 
00088         ticks ticksGet() const { return getTicks(); }
00089 
00095         ticks getTicks() const;
00096 
00104         ticks ticksGet( ticks &relativeTime ) const { return getTicks( relativeTime ); }
00105 
00112         ticks getTicks( ticks &relativeTime ) const;
00113 
00120         ticks ticksSince( ticks relativeTime ) const;
00121 
00131         Seconds secondsGet( ticks &relativeTime ) const { return getSeconds(relativeTime); }
00132 
00141         Seconds getSeconds( ticks &relativeTime ) const;
00142 
00149         Seconds secondsSince( ticks relativeTime ) const;
00150 
00155         Seconds secondsChange( Seconds delta );
00156 
00162         void enableSystemClock( bool yes_no );
00163         
00169         nsecs getNSecs() const;
00170 
00177         nsecs getNSecs( nsecs &relativeTime ) const;
00178 
00184         static ticks nsecs2ticks( const nsecs m );
00185 
00189         static nsecs ticks2nsecs( const ticks t );
00190 
00194         static const ticks InfiniteTicks;
00195 
00199         static const nsecs InfiniteNSecs;
00200 
00204         static const Seconds InfiniteSeconds;
00205     protected:
00206 
00210         TimeService();
00211 
00212     private:
00213 
00217         static TimeService* _instance;
00218 
00222         ticks offset;
00223 
00224         bool use_clock;
00225     };
00226 } // namespace RTT
00227 
00228 #endif

Generated on Tue Mar 25 17:41:52 2008 for OrocosReal-TimeToolkit by  doxygen 1.5.3