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 #include <time.h>
22 #include <cob_utilities/StrUtil.h>
23 
24 //-------------------------------------------------------------------
25 
31 class TimeStamp
32 {
33  public:
35  TimeStamp();
36 
38  virtual ~TimeStamp() {};
39 
41  void SetNow();
42 
44  double operator- ( const TimeStamp& EarlierTime ) const;
45 
47 
49  void operator+= ( double TimeS );
50 
52 
54  void operator-= ( double TimeS );
55 
57  bool operator> ( const TimeStamp& Time );
58 
60  bool operator< ( const TimeStamp& Time );
61 
65  void getTimeStamp ( long& lSeconds, long& lNanoSeconds );
66 
70  void setTimeStamp ( const long& lSeconds, const long& lNanoSeconds );
71 
76  std::string CurrentToString();
77 
78  std::string ToString();
79 
80  protected:
81 
83  timespec m_TimeStamp;
84 
85  private:
86 
88  static double TimespecToDouble ( const ::timespec& LargeInt );
89 
91  static ::timespec DoubleToTimespec ( double TimeS );
92 
93 };
94 
95 
96 #endif
97 
void setTimeStamp(const long &lSeconds, const long &lNanoSeconds)
Definition: TimeStamp.cpp:116
timespec m_TimeStamp
Internal time stamp data.
Definition: TimeStamp.h:83
void operator-=(double TimeS)
Reduces the timestamp by TimeS seconds.
Definition: TimeStamp.cpp:82
void getTimeStamp(long &lSeconds, long &lNanoSeconds)
Definition: TimeStamp.cpp:110
void SetNow()
Makes time measurement.
Definition: TimeStamp.cpp:28
TimeStamp()
Constructor.
Definition: TimeStamp.cpp:22
void operator+=(double TimeS)
Increase the timestamp by TimeS seconds.
Definition: TimeStamp.cpp:70
bool operator>(const TimeStamp &Time)
Checks if this time is after time "Time".
Definition: TimeStamp.cpp:94
bool operator<(const TimeStamp &Time)
Checks if this time is before time "Time".
Definition: TimeStamp.cpp:102
std::string CurrentToString()
Definition: TimeStamp.cpp:122
double operator-(const TimeStamp &EarlierTime) const
Retrieves time difference in seconds.
Definition: TimeStamp.cpp:55
virtual ~TimeStamp()
Destructor.
Definition: TimeStamp.h:38
static double TimespecToDouble(const ::timespec &LargeInt)
Conversion timespec -> double.
Definition: TimeStamp.cpp:33
std::string ToString()
Definition: TimeStamp.cpp:142
::timespec DoubleToTimespec(double TimeS)
Conversion double -> timespec.
Definition: TimeStamp.cpp:38


cob_utilities
Author(s): Christian Connette
autogenerated on Wed Apr 7 2021 02:11:52