TimeStamp.hh
Go to the documentation of this file.
1 
42 #ifndef CRL_MULTISENSE_TIMESTAMP_HH
43 #define CRL_MULTISENSE_TIMESTAMP_HH
44 
45 #if defined(WIN32)
46 #ifndef WIN32_LEAN_AND_MEAN
47 #define WIN32_LEAN_AND_MEAN 1
48 #endif
49 
50 #include <windows.h>
51 #include <winsock2.h> // Provides a declaration for struct timeval
52 #else
53 #include <sys/time.h>
54 #endif
55 #include <stdint.h>
56 
57 namespace crl {
58 namespace multisense {
59 namespace details {
60 namespace utility {
61 
62 //
63 // This is a simple class that helps manage time for the rest of the system,
64 // abstracting it away into something that is more usable.
65 //
66 
67 class TimeStamp
68 {
69 private:
70 
71  //
72  // The stored time.
73  //
74 
75  struct timeval time;
76 
77 #if defined (WIN32)
78  static ULARGE_INTEGER offsetSecondsSince1970;
79 #endif
80 
81 public:
82 
83  //
84  // Static routines, for the singleton version of the TimeStamp.
85  //
86 
87  static TimeStamp getCurrentTime();
88 
89  //
90  // Public constructor. Initializes from a timestamp.
91  //
92 
93  TimeStamp();
94  TimeStamp(int32_t seconds, int32_t microSeconds);
95  TimeStamp(int64_t nanoseconds);
96  TimeStamp(const struct timeval& value);
97  //
98  // For setting the timestamp.
99  //
100 
101  void set(const struct timeval& value);
102  void set(int32_t seconds, int32_t microSeconds);
103 
104  //
105  // For getting precise values from the timestamp.
106  //
107 
108  int32_t getSeconds() const;
109  int32_t getMicroSeconds() const;
110 
111  //
112  // Get the time in nanoseconds
113  //
114 
115  int64_t getNanoSeconds() const;
116 
117  //
118  // Operator overloads, for working with time.
119  //
120 
121  TimeStamp operator+(TimeStamp const& other) const;
122  TimeStamp operator-(TimeStamp const& other) const;
123  TimeStamp& operator+=(TimeStamp const& other);
124  TimeStamp& operator-=(TimeStamp const& other);
125 };
126 
127 }}}} // namespaces
128 
129 #endif /* #ifndef CRL_MULTISENSE_TIMESTAMP_HH */
TimeStamp & operator+=(TimeStamp const &other)
Definition: TimeStamp.cc:264
TimeStamp & operator-=(TimeStamp const &other)
Definition: TimeStamp.cc:270
Definition: channel.cc:58
TimeStamp operator+(TimeStamp const &other) const
Definition: TimeStamp.cc:246
TimeStamp operator-(TimeStamp const &other) const
Definition: TimeStamp.cc:255


multisense_lib
Author(s):
autogenerated on Sat Jun 24 2023 03:01:21