OpenAB  1.0.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
TimeStamp.hpp
Go to the documentation of this file.
1 /*
2  * This Source Code Form is subject to the terms of the Mozilla Public
3  * License, v. 2.0. If a copy of the MPL was not distributed with this
4  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
5  */
10 #ifndef TIMESTAMP_HPP_
11 #define TIMESTAMP_HPP_
12 
13 #include <sys/time.h>
14 #include <string>
15 
19 namespace OpenAB {
20 
25 class TimeStamp
26 {
27  public:
31  TimeStamp();
32 
33  TimeStamp(bool current);
34 
35  TimeStamp(__time_t s, __suseconds_t us);
36 
40  virtual ~TimeStamp();
41 
42  TimeStamp operator+ (const TimeStamp& other) const;
43  TimeStamp operator- (const TimeStamp& other) const;
44 
45  TimeStamp& operator+= (const TimeStamp& other);
46  TimeStamp& operator-= (const TimeStamp& other);
47 
48  bool operator< (const TimeStamp& other) const;
49  bool operator<= (const TimeStamp& other) const;
50  bool operator> (const TimeStamp& other) const;
51  bool operator>= (const TimeStamp& other) const;
52 
53  void setNow();
54 
55  unsigned int toMs() const;
56 
57  std::string toString() const;
58 
59  private:
60 
61  struct timeval timestamp;
62 };
63 
64 } // namespace OpenAB
65 
66 #endif // TIMESTAMP_HPP_
TimeStamp operator-(const TimeStamp &other) const
Definition: TimeStamp.cpp:58
Class representing time stamp. Allows for basic operations like adding and subtracting time stamps...
Definition: TimeStamp.hpp:25
TimeStamp operator+(const TimeStamp &other) const
Definition: TimeStamp.cpp:49
bool operator>=(const TimeStamp &other) const
Definition: TimeStamp.cpp:102
TimeStamp & operator+=(const TimeStamp &other)
Definition: TimeStamp.cpp:67
TimeStamp & operator-=(const TimeStamp &other)
Definition: TimeStamp.cpp:76
void setNow()
Definition: TimeStamp.cpp:44
virtual ~TimeStamp()
Destructor, virtual by default.
Definition: TimeStamp.cpp:40
bool operator<=(const TimeStamp &other) const
Definition: TimeStamp.cpp:91
bool operator<(const TimeStamp &other) const
Definition: TimeStamp.cpp:85
unsigned int toMs() const
Definition: TimeStamp.cpp:115
bool operator>(const TimeStamp &other) const
Definition: TimeStamp.cpp:96
std::string toString() const
Definition: TimeStamp.cpp:108
TimeStamp()
Constructor.
Definition: TimeStamp.cpp:15