TimeService.hpp
Go to the documentation of this file.
1 /***************************************************************************
2  tag: Peter Soetens Wed Apr 17 16:01:36 CEST 2002 TimeService.h
3 
4  TimeService.h - description
5  -------------------
6  begin : Wed April 17 2002
7  copyright : (C) 2002 Peter Soetens
8  email : peter.soetens@mech.kuleuven.ac.be
9 
10  ***************************************************************************
11  * This library is free software; you can redistribute it and/or *
12  * modify it under the terms of the GNU General Public *
13  * License as published by the Free Software Foundation; *
14  * version 2 of the License. *
15  * *
16  * As a special exception, you may use this file as part of a free *
17  * software library without restriction. Specifically, if other files *
18  * instantiate templates or use macros or inline functions from this *
19  * file, or you compile this file and link it with other files to *
20  * produce an executable, this file does not by itself cause the *
21  * resulting executable to be covered by the GNU General Public *
22  * License. This exception does not however invalidate any other *
23  * reasons why the executable file might be covered by the GNU General *
24  * Public License. *
25  * *
26  * This library is distributed in the hope that it will be useful, *
27  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
28  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
29  * General Public License for more details. *
30  * *
31  * You should have received a copy of the GNU General Public *
32  * License along with this library; if not, write to the Free Software *
33  * Foundation, Inc., 59 Temple Place, *
34  * Suite 330, Boston, MA 02111-1307 USA *
35  * *
36  ***************************************************************************/
37 
38 
39 #ifndef RTT_TIME_SERVICE_HPP
40 #define RTT_TIME_SERVICE_HPP
41 
42 #include "Time.hpp"
43 #include "../rtt-config.h"
44 
45 namespace RTT
46 { namespace os {
47 
48 
53  class RTT_API TimeService
54  {
55  public:
59  typedef double Seconds;
60 
64  typedef long secs;
65 
69  typedef long msecs;
70 
74  typedef long usecs;
75 
79  typedef long long nsecs;
80 
84  typedef long long ticks;
85 
86  public:
87  static TimeService* Instance();
88 
95  static bool Release();
96 
100  virtual ~TimeService();
101 
108  ticks ticksGet() const { return getTicks(); }
109 
115  ticks getTicks() const;
116 
124  ticks ticksGet( ticks &relativeTime ) const { return getTicks( relativeTime ); }
125 
132  ticks getTicks( ticks &relativeTime ) const;
133 
140  ticks ticksSince( ticks relativeTime ) const;
141 
151  Seconds secondsGet( ticks &relativeTime ) const { return getSeconds(relativeTime); }
152 
161  Seconds getSeconds( ticks &relativeTime ) const;
162 
169  Seconds secondsSince( ticks relativeTime ) const;
170 
175  Seconds secondsChange( Seconds delta );
176 
181  ticks ticksChange( ticks delta );
182 
188  void enableSystemClock( bool yes_no );
189 
194  bool systemClockEnabled() const;
195 
201  nsecs getNSecs() const;
202 
209  nsecs getNSecs( nsecs &relativeTime ) const;
210 
216  static ticks nsecs2ticks( const nsecs m );
217 
221  static nsecs ticks2nsecs( const ticks t );
222 
226  static const ticks InfiniteTicks;
227 
231  static const nsecs InfiniteNSecs;
232 
236  static const Seconds InfiniteSeconds;
237  protected:
238 
242  TimeService();
243 
244  private:
245 
250 
254  ticks offset;
255 
256  bool use_clock;
257  };
258 }} // namespace RTT
259 
260 #endif
static TimeService * _instance
static const ticks InfiniteTicks
ticks ticksGet() const
static const nsecs InfiniteNSecs
Seconds secondsGet(ticks &relativeTime) const
static const Seconds InfiniteSeconds
ticks ticksGet(ticks &relativeTime) const
Contains TaskContext, Activity, OperationCaller, Operation, Property, InputPort, OutputPort, Attribute.
Definition: Activity.cpp:53


rtt
Author(s): RTT Developers
autogenerated on Tue Jun 25 2019 19:33:37