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 
11 #include "../BasicDatatypes.hpp"
12 #include <sys/time.h>
13 #include <time.h>
14 
15 // Eine Zeitspanne, in [s]
17 {
18 public:
19  TimeDuration();
20  TimeDuration(double seconds) { m_duration = seconds; }
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;
30 inline TimeDuration& TimeDuration::operator=(const double& seconds)
31 {
32  m_duration = seconds;
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
std::string toString(const PositionWGS84::PositionWGS84SourceType &type)
UINT32 total_milliseconds()
Definition: Time.hpp:37
TimeDuration(double seconds)
Definition: Time.hpp:20
const Point2D operator-(const Point2D &p1, const Point2D &p2)
Definition: Point2D.hpp:321
Definition: Time.hpp:44
static const double m_nanosecondsToSecondFractionNTP
Definition: Time.hpp:78
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
static const double m_secondFractionNTPtoNanoseconds
Definition: Time.hpp:77
bool operator==(const Box2D &b1, const Box2D &b2)
Definition: Box2D.hpp:269
uint64_t UINT64
const Point2D operator+(const Point2D &p1, const Point2D &p2)
Definition: Point2D.hpp:316


libsick_ldmrs
Author(s): SICK AG , Martin Günther , Jochen Sprickerhof
autogenerated on Sat Jun 8 2019 17:57:33