BitmapToolkit Scol plugin
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>
14using namespace std;
15
16namespace DUtils {
17
20{
21public:
22
25 {
26 NONE = 0,
28 ZERO = 0x2
29 };
30
31public:
32
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
194protected:
196 unsigned long m_secs; // seconds
198 unsigned long m_usecs; // microseconds
199};
200
201}
202
203#endif
204
Timestamp.
Definition Timestamp.h:20
virtual ~Timestamp(void)
Definition Timestamp.cpp:47
bool empty() const
Definition Timestamp.cpp:51
Timestamp operator+(double s) const
void getTime(unsigned long &secs, unsigned long &usecs) const
Definition Timestamp.h:71
double getFloatTime() const
Definition Timestamp.cpp:94
bool operator==(const Timestamp &t) const
void setTime(unsigned long secs, unsigned long usecs)
Definition Timestamp.h:61
bool operator<=(const Timestamp &t) const
Timestamp minus(unsigned long s, unsigned long us) const
tOptions
Options to initiate a timestamp.
Definition Timestamp.h:25
bool operator<(const Timestamp &t) const
Timestamp & operator+=(double s)
Timestamp & operator-=(double s)
unsigned long m_secs
Seconds.
Definition Timestamp.h:196
Timestamp plus(unsigned long s, unsigned long us) const
double operator-(const Timestamp &t) const
string Format(bool machine_friendly=false) const
bool operator>(const Timestamp &t) const
bool operator>=(const Timestamp &t) const
void setToCurrentTime()
Definition Timestamp.cpp:56
string getStringTime() const
Definition Timestamp.cpp:98
unsigned long m_usecs
Microseconds.
Definition Timestamp.h:198