Timestamp.h
Go to the documentation of this file.
1 /*
2  * File: Timestamp.h
3  * Author: Dorian Galvez-Lopez
4  * Date: March 2009
5  * Description: timestamping functions
6  * License: see the LICENSE.txt file
7  *
8  */
9 
10 #ifndef __D_TIMESTAMP__
11 #define __D_TIMESTAMP__
12 
13 #include <iostream>
14 using namespace std;
15 
16 namespace DUtils {
17 
19 class Timestamp
20 {
21 public:
22 
24  enum tOptions
25  {
26  NONE = 0,
27  CURRENT_TIME = 0x1,
28  ZERO = 0x2
29  };
30 
31 public:
32 
37  Timestamp(Timestamp::tOptions option = NONE);
38 
42  virtual ~Timestamp(void);
43 
49  bool empty() const;
50 
54  void setToCurrentTime();
55 
61  inline void setTime(unsigned long secs, unsigned long usecs){
62  m_secs = secs;
63  m_usecs = usecs;
64  }
65 
71  inline void getTime(unsigned long &secs, unsigned long &usecs) const
72  {
73  secs = m_secs;
74  usecs = m_usecs;
75  }
76 
81  void setTime(const string &stime);
82 
87  void setTime(double s);
88 
92  double getFloatTime() const;
93 
97  string getStringTime() const;
98 
105  double operator- (const Timestamp &t) const;
106 
112  Timestamp plus(unsigned long s, unsigned long us) const;
113 
119  Timestamp minus(unsigned long s, unsigned long us) const;
120 
126  Timestamp& operator+= (double s);
127 
133  Timestamp& operator-= (double s);
134 
139  Timestamp operator+ (double s) const;
140 
145  Timestamp operator- (double s) const;
146 
151  bool operator> (const Timestamp &t) const;
152 
157  bool operator>= (const Timestamp &t) const;
158 
163  bool operator== (const Timestamp &t) const;
164 
169  bool operator< (const Timestamp &t) const;
170 
175  bool operator<= (const Timestamp &t) const;
176 
184  string Format(bool machine_friendly = false) const;
185 
191  static string Format(double s);
192 
193 
194 protected:
196  unsigned long m_secs; // seconds
198  unsigned long m_usecs; // microseconds
199 };
200 
201 }
202 
203 #endif
204 
XmlRpcServer s
Definition: Random.h:18
tOptions
Options to initiate a timestamp.
Definition: Timestamp.h:24
void getTime(unsigned long &secs, unsigned long &usecs) const
Definition: Timestamp.h:71
Timestamp.
Definition: Timestamp.h:19
void setTime(unsigned long secs, unsigned long usecs)
Definition: Timestamp.h:61
bool operator<(const HyperDijkstra::AdjacencyMapEntry &a, const HyperDijkstra::AdjacencyMapEntry &b)
unsigned long m_secs
Seconds.
Definition: Timestamp.h:196
unsigned long m_usecs
Microseconds.
Definition: Timestamp.h:198
Format


orb_slam2_ros
Author(s):
autogenerated on Wed Apr 21 2021 02:53:05