TimeStamp.h
Go to the documentation of this file.
1 /*
2  * Copyright 2017 Fraunhofer Institute for Manufacturing Engineering and Automation (IPA)
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9 
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 
18 #ifndef _TimeStamp_H
19 #define _TimeStamp_H
20 
21 #ifdef __LINUX__
22 #include <time.h>
23 #else
24 #include <windows.h>
25 #ifdef _DEBUG
26 //#define new DEBUG_NEW
27 #undef THIS_FILE
28 static char THIS_FILE[] = __FILE__;
29 #endif
30 namespace RTB
31 {
32 
33 #endif
34 
35 //-------------------------------------------------------------------
36 
42 class TimeStamp
43 {
44 public:
46  TimeStamp();
47 
49  virtual ~TimeStamp(){};
50 
52  void SetNow();
53 
55  double operator-(const TimeStamp& EarlierTime) const;
56 
58 
60  void operator+=(double TimeS);
61 
63 
65  void operator-=(double TimeS);
66 
68  bool operator>(const TimeStamp& Time);
69 
71  bool operator<(const TimeStamp& Time);
72 
76  void getTimeStamp(long& lSeconds, long& lNanoSeconds);
77 
81  void setTimeStamp(const long& lSeconds, const long& lNanoSeconds);
82 
83 protected:
85 #ifdef __LINUX__
86  timespec m_TimeStamp;
87 #else
88  LARGE_INTEGER m_TimeStamp;
89 #endif
90 
91 private:
93 #ifdef __LINUX__
94  static double TimespecToDouble(const ::timespec& LargeInt);
95 
97  static ::timespec DoubleToTimespec(double TimeS);
98 #else
99  static double LargeIntToDouble(const LARGE_INTEGER& LargeInt);
100 
102  static LARGE_INTEGER DoubleToLargeInt(double TimeS);
103 
105  static double m_DwordSize;
106 
108  static double m_SecPerCount;
109 #endif
110 };
111 
112 #ifdef __LINUX__
113 #else
114 } // namespace
115 #endif
116 #endif
static double m_SecPerCount
Seconds per counts.
Definition: TimeStamp.h:108
void setTimeStamp(const long &lSeconds, const long &lNanoSeconds)
void operator+=(double TimeS)
Increase the timestamp by TimeS seconds.
Definition: TimeStamp.cpp:179
static double LargeIntToDouble(const LARGE_INTEGER &LargeInt)
Conversion timespec -> double.
Definition: TimeStamp.cpp:153
double operator-(const TimeStamp &EarlierTime) const
Retrieves time difference in seconds.
Definition: TimeStamp.cpp:169
LARGE_INTEGER m_TimeStamp
Internal time stamp data.
Definition: TimeStamp.h:88
bool operator>(const TimeStamp &Time)
Checks if this time is after time "Time".
Definition: TimeStamp.cpp:201
TimeStamp()
Constructor.
Definition: TimeStamp.cpp:142
bool operator<(const TimeStamp &Time)
Checks if this time is before time "Time".
Definition: TimeStamp.cpp:210
static double m_DwordSize
Size of a Dword field.
Definition: TimeStamp.h:105
void SetNow()
Makes time measurement.
Definition: TimeStamp.cpp:148
void operator-=(double TimeS)
Reduces the timestamp by TimeS seconds.
Definition: TimeStamp.cpp:189
void getTimeStamp(long &lSeconds, long &lNanoSeconds)
Definition: TimeStamp.h:30
static LARGE_INTEGER DoubleToLargeInt(double TimeS)
Conversion double -> LARGE_INTEGER.
Definition: TimeStamp.cpp:158
virtual ~TimeStamp()
Destructor.
Definition: TimeStamp.h:49


schunk_powercube_chain
Author(s): Florian Weisshardt
autogenerated on Mon Nov 25 2019 03:48:21