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
Time::m_secondFractionNTPtoNanoseconds
static const double m_secondFractionNTPtoNanoseconds
Definition: Time.hpp:77
Time::now
static Time now()
Definition: Time.cpp:168
Time::operator+=
Time & operator+=(const Time &other)
Definition: Time.cpp:122
Time::toLongString
std::string toLongString() const
Definition: Time.cpp:51
Time::secondsFrom1900to1970
static const UINT64 secondsFrom1900to1970
Definition: Time.hpp:72
Time::operator>=
bool operator>=(const Time &other) const
Definition: Time.cpp:179
Time::toString
std::string toString() const
Definition: Time.cpp:40
Time::operator+
Time operator+(const TimeDuration &dur) const
Definition: Time.cpp:153
time.h
BasicDatatypes.hpp
Time::m_time
timeval m_time
Definition: Time.hpp:75
Time::~Time
~Time()
Definition: Time.cpp:32
Time::set
void set(double time)
Definition: Time.cpp:69
UINT64
uint64_t UINT64
Definition: BasicDatatypes.hpp:24
TimeDuration::set
void set(double seconds)
Definition: Time.hpp:22
TimeDuration::TimeDuration
TimeDuration()
Definition: Time.cpp:14
Time::operator-
Time operator-(const Time &other) const
Definition: Time.cpp:230
TimeDuration::m_duration
double m_duration
Definition: Time.hpp:26
TimeDuration::TimeDuration
TimeDuration(double seconds)
Definition: Time.hpp:20
Time
Definition: Time.hpp:44
TimeDuration
Definition: Time.hpp:16
ROS::seconds
double seconds(ROS::Duration duration)
Definition: ros_wrapper.cpp:180
Time::total_milliseconds
UINT32 total_milliseconds()
Definition: Time.cpp:111
Time::operator<
bool operator<(const Time &other) const
Definition: Time.cpp:197
Time::Time
Time()
Definition: Time.cpp:27
UINT32
uint32_t UINT32
Definition: BasicDatatypes.hpp:26
Time::m_nanosecondsToSecondFractionNTP
static const double m_nanosecondsToSecondFractionNTP
Definition: Time.hpp:78
Time::operator==
bool operator==(const Time &other) const
Definition: Time.cpp:217
TimeDuration::operator=
TimeDuration & operator=(const double &seconds)
Definition: Time.hpp:30
TimeDuration::total_milliseconds
UINT32 total_milliseconds()
Definition: Time.hpp:37
Time::seconds
double seconds()
Definition: Time.cpp:102


sick_scan
Author(s): Michael Lehning , Jochen Sprickerhof , Martin Günther
autogenerated on Thu Sep 8 2022 02:30:19