Orocos Real-Time Toolkit  2.6.0
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 RTT_TIME_SERVICE_HPP
00022 #define RTT_TIME_SERVICE_HPP
00023 
00024 #include "Time.hpp"
00025 #include "../rtt-config.h"
00026 
00027 namespace RTT
00028 { namespace os {
00029 
00030 
00035     class RTT_API TimeService
00036     {
00037     public:
00041         typedef double Seconds;
00042 
00046         typedef long secs;
00047 
00051         typedef long msecs;
00052 
00056         typedef long usecs;
00057 
00061         typedef long long nsecs;
00062 
00066         typedef long long ticks;
00067 
00068     public:
00069         static TimeService* Instance();
00070 
00077         static bool Release();
00078 
00082         virtual ~TimeService();
00083 
00090         ticks ticksGet() const { return getTicks(); }
00091 
00097         ticks getTicks() const;
00098 
00106         ticks ticksGet( ticks &relativeTime ) const { return getTicks( relativeTime ); }
00107 
00114         ticks getTicks( ticks &relativeTime ) const;
00115 
00122         ticks ticksSince( ticks relativeTime ) const;
00123 
00133         Seconds secondsGet( ticks &relativeTime ) const { return getSeconds(relativeTime); }
00134 
00143         Seconds getSeconds( ticks &relativeTime ) const;
00144 
00151         Seconds secondsSince( ticks relativeTime ) const;
00152 
00157         Seconds secondsChange( Seconds delta );
00158 
00164         void enableSystemClock( bool yes_no );
00165 
00171         nsecs getNSecs() const;
00172 
00179         nsecs getNSecs( nsecs &relativeTime ) const;
00180 
00186         static ticks nsecs2ticks( const nsecs m );
00187 
00191         static nsecs ticks2nsecs( const ticks t );
00192 
00196         static const ticks InfiniteTicks;
00197 
00201         static const nsecs InfiniteNSecs;
00202 
00206         static const Seconds InfiniteSeconds;
00207     protected:
00208 
00212         TimeService();
00213 
00214     private:
00215 
00219         static TimeService* _instance;
00220 
00224         ticks offset;
00225 
00226         bool use_clock;
00227     };
00228 }} // namespace RTT
00229 
00230 #endif