IBR-DTNSuite  0.12
MonotonicClock.h
Go to the documentation of this file.
1 /*
2  * MonotonicClock.h
3  *
4  * Created on: 10.09.2013
5  * Author: morgenro
6  */
7 
8 #ifndef MONOTONICCLOCK_H_
9 #define MONOTONICCLOCK_H_
10 
11 #include <sys/time.h>
12 #include <sys/types.h>
13 #include <stdint.h>
14 
19 #ifdef __WIN32__
20 #include <windows.h>
21 #include <pthread.h>
22 #endif
23 
24 namespace ibrcommon {
25 
27  public:
29  virtual ~MonotonicClock();
30 
31  void get(struct timeval &tv) const;
32  void get(struct timespec &ts) const;
33  time_t getSeconds() const;
34 
35  static void gettime(struct timeval &tv);
36  static void gettime(struct timespec &ts);
37 
38  static void diff(const struct timespec &start, const struct timespec &end, struct timespec &diff);
39 
40  private:
41 #ifdef __WIN32__
42  static LARGE_INTEGER getFILETIMEoffset();
43 #endif
44 
45  struct timespec _start;
46  };
47 
48 } /* namespace ctrl */
49 #endif /* MONOTONICCLOCK_H_ */