automotive-message-broker  0.14.803
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Groups Pages
timestamp.h
1 #ifndef _TIMESTAMP_H___
2 #define _TIMESTAMP_H___
3 
4 #include <time.h>
5 #include <linux/can/bcm.h>
6 
7 #ifndef HAVE_BCM_TIMEVAL
8 
9 #define bcm_timeval timeval
10 
11 #endif
12 
13 namespace amb {
14 
15 double currentTime();
16 
25 class Timestamp {
26 protected:
27  Timestamp();
28 
29 public:
30 
35  double currentTime();
36  double currentTime(double time);
37 
43  double epochTime(double time);
44 
49  double epochTime();
50 
51  static double fromTimeval(const struct ::timeval& tv);
52  static struct ::timeval toTimeval(const double time);
53 
54  static struct ::bcm_timeval toBcmTimeval(const double time);
55 
56 public:
61  static Timestamp *instance();
62 
63 private:
64  double startTimeEpoch;
65  static Timestamp* mInstance;
66 };
67 
68 }
69 
70 #endif