Time.hpp
Go to the documentation of this file.
1 // Time.hpp
2 //
3 // created: June 6, 2011
4 //
5 // Mit "-lrt" linken!!
6 //
7 
8 #ifndef TIME_HPP
9 #define TIME_HPP
10 
12 #include <sys/time.h>
13 #include <time.h>
14 
15 // Eine Zeitspanne, in [s]
17 {
18 public:
19  TimeDuration();
21 
22  void set(double seconds) { m_duration = seconds; }
23  inline UINT32 total_milliseconds();
24  inline TimeDuration& operator=(const double& seconds);
25 
26  double m_duration; // Zeit, in [s]
27 };
28 
29 // Fuer td = x;
31 {
33  return *this;
34 }
35 
36 // Zeitspanne als [ms]
38 {
39  UINT32 ms = (UINT32)((m_duration * 1000.0) + 0.5);
40  return ms;
41 }
42 
43 
44 class Time
45 {
46 public:
47  Time();
48  Time(timeval time);
49  ~Time();
50 
51  void set(double time);
52  void set(timeval time);
53  void set(UINT64 ntpSeconds, UINT32 ntpFractionalSeconds);
54  void set(UINT64 ntpTime);
55  double seconds();
57 
58  static Time now(); // Returns the current time
59 
60  Time operator+(const TimeDuration& dur) const;
61  Time& operator+=(const Time& other);
62  Time operator+(const Time& other) const;
63  Time operator-(const Time& other) const;
64  Time operator-(const double& seconds) const;
65  bool operator>=(const Time& other) const;
66  bool operator<(const Time& other) const;
67  bool operator==(const Time& other) const;
68 
69  std::string toString() const;
70  std::string toLongString() const;
71 
73 
74 private:
75  timeval m_time; // Zeit, in [s]
76 
77  static const double m_secondFractionNTPtoNanoseconds; // = 2^-32 * 1e9
78  static const double m_nanosecondsToSecondFractionNTP; // = 2^32 * 1e-9
79 };
80 
81 
82 #endif // TIME_HPP
static const UINT64 secondsFrom1900to1970
Definition: Time.hpp:72
UINT32 total_milliseconds()
Definition: Time.hpp:37
TFSIMD_FORCE_INLINE Quaternion operator-(const Quaternion &q)
bool operator<(const TiXmlString &a, const TiXmlString &b)
Definition: tinystr.h:276
TimeDuration(double seconds)
Definition: Time.hpp:20
Definition: Time.hpp:44
static const double m_nanosecondsToSecondFractionNTP
Definition: Time.hpp:78
ROS::Time now(void)
TiXmlString operator+(const TiXmlString &a, const TiXmlString &b)
Definition: tinystr.cpp:81
uint32_t UINT32
timeval m_time
Definition: Time.hpp:75
TimeDuration & operator=(const double &seconds)
Definition: Time.hpp:30
TimeDuration()
Definition: Time.cpp:14
double m_duration
Definition: Time.hpp:26
bool operator==(const TiXmlString &a, const TiXmlString &b)
Definition: tinystr.h:270
TFSIMD_FORCE_INLINE Vector3 & operator+=(const Vector3 &v)
static const double m_secondFractionNTPtoNanoseconds
Definition: Time.hpp:77
std::string toString(INT32 value)
Definition: toolbox.cpp:279
bool operator>=(const TiXmlString &a, const TiXmlString &b)
Definition: tinystr.h:290
uint64_t UINT64
double seconds(ROS::Duration duration)


sick_scan
Author(s): Michael Lehning , Jochen Sprickerhof , Martin Günther
autogenerated on Wed May 5 2021 03:05:48