CMS 3D CMS Logo

TimeSpec.h
Go to the documentation of this file.
1 
2 #ifndef DataFormats_Scalers_TimeSpec_h
3 #define DataFormats_Scalers_TimeSpec_h
4 
5 #include <ctime>
6 
7 class TimeSpec {
8 public:
9  TimeSpec() : tv_sec_(0), tv_nsec_(0) {}
10 
11  TimeSpec(long tv_sec, long tv_nsec) : tv_sec_(tv_sec), tv_nsec_(tv_nsec) {}
12 
13  TimeSpec(timespec const& ts) : tv_sec_(static_cast<long>(ts.tv_sec)), tv_nsec_(static_cast<long>(ts.tv_nsec)) {}
14 
15  long tv_sec() const { return tv_sec_; }
16  long tv_nsec() const { return tv_nsec_; }
17 
18  void set_tv_sec(long value) { tv_sec_ = value; }
19  void set_tv_nsec(long value) { tv_nsec_ = value; }
20 
21  timespec get_timespec() const;
22 
23 private:
24  long tv_sec_; // seconds
25  long tv_nsec_; // nanoseconds
26 };
27 
28 #endif
long tv_sec() const
Definition: TimeSpec.h:15
void set_tv_nsec(long value)
Definition: TimeSpec.h:19
long tv_nsec() const
Definition: TimeSpec.h:16
timespec get_timespec() const
Definition: TimeSpec.cc:4
long tv_sec_
Definition: TimeSpec.h:24
TimeSpec(long tv_sec, long tv_nsec)
Definition: TimeSpec.h:11
long tv_nsec_
Definition: TimeSpec.h:25
TimeSpec()
Definition: TimeSpec.h:9
Definition: value.py:1
TimeSpec(timespec const &ts)
Definition: TimeSpec.h:13
void set_tv_sec(long value)
Definition: TimeSpec.h:18