CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
Timestamp.h
Go to the documentation of this file.
1 #ifndef DataFormats_Provenance_Timestamp_h
2 #define DataFormats_Provenance_Timestamp_h
3 // -*- C++ -*-
4 //
5 // Package: DataFormats/Provenance
6 // Class: Timestamp
7 //
16 //
17 // Author: Chris Jones
18 // Created: Thu Mar 24 16:23:05 EST 2005
19 //
20 
21 // system include files
22 #include<limits>
23 
24 // user include files
25 
26 // forward declarations
27 namespace edm {
28  typedef unsigned long long TimeValue_t;
29 
30 class Timestamp {
31 
32  static const TimeValue_t kLowMask=0xFFFFFFFF;
33 
34  public:
35  explicit Timestamp(TimeValue_t iValue):
36  timeLow_(static_cast<unsigned int>(kLowMask & iValue)),
37  timeHigh_(static_cast<unsigned int>(iValue >> 32)){}
38 
39 
42 
43 
45  unsigned int
46  unixTime() const {
47  return timeHigh_;
48  }
49 
51  unsigned int
53  return timeLow_;
54  }
55 
56  TimeValue_t value() const {
57  TimeValue_t returnValue = timeHigh_;
58  returnValue = returnValue << 32;
59  returnValue += timeLow_;
60  return returnValue;
61  }
62 
63 
64 
65 
66  // ---------- const member functions ---------------------
67  bool operator==(Timestamp const& iRHS) const {
68  return timeHigh_ == iRHS.timeHigh_ &&
69  timeLow_ == iRHS.timeLow_;
70  }
71  bool operator!=(Timestamp const& iRHS) const {
72  return !(*this == iRHS);
73  }
74 
75  bool operator<(Timestamp const& iRHS) const {
76  if(timeHigh_ == iRHS.timeHigh_) {
77  return timeLow_ < iRHS.timeLow_;
78  }
79  return timeHigh_ < iRHS.timeHigh_;
80  }
81  bool operator<=(Timestamp const& iRHS) const {
82  if(timeHigh_ == iRHS.timeHigh_) {
83  return timeLow_ <= iRHS.timeLow_;
84  }
85  return timeHigh_ <= iRHS.timeHigh_;
86  }
87  bool operator>(Timestamp const& iRHS) const {
88  if(timeHigh_ == iRHS.timeHigh_) {
89  return timeLow_ > iRHS.timeLow_;
90  }
91  return timeHigh_ > iRHS.timeHigh_;
92  }
93  bool operator>=(Timestamp const& iRHS) const {
94  if(timeHigh_ == iRHS.timeHigh_) {
95  return timeLow_ >= iRHS.timeLow_;
96  }
97  return timeHigh_ >= iRHS.timeHigh_;
98  }
99 
100  // ---------- static member functions --------------------
101  static Timestamp invalidTimestamp() { return Timestamp(0);}
103  static Timestamp beginOfTime() {return Timestamp(1);}
104 
105  // ---------- member functions ---------------------------
106 
107  private:
108  //Timestamp(Timestamp const&); // allow default
109 
110  //Timestamp const& operator=(Timestamp const&); // allow default
111 
112  // ---------- member data --------------------------------
113  // ROOT does not support ULL
114  //TimeValue_t time_;
115  unsigned int timeLow_;
116  unsigned int timeHigh_;
117 };
118 
119 }
120 #endif
static Timestamp endOfTime()
Definition: Timestamp.h:102
static Timestamp invalidTimestamp()
Definition: Timestamp.h:101
bool operator!=(Timestamp const &iRHS) const
Definition: Timestamp.h:71
Timestamp(TimeValue_t iValue)
Definition: Timestamp.h:35
unsigned int microsecondOffset() const
Microseconds offset within second.
Definition: Timestamp.h:52
bool operator<=(Timestamp const &iRHS) const
Definition: Timestamp.h:81
unsigned int timeHigh_
Definition: Timestamp.h:116
bool operator>=(Timestamp const &iRHS) const
Definition: Timestamp.h:93
static Timestamp beginOfTime()
Definition: Timestamp.h:103
bool operator>(Timestamp const &iRHS) const
Definition: Timestamp.h:87
const T & max(const T &a, const T &b)
bool operator<(Timestamp const &iRHS) const
Definition: Timestamp.h:75
unsigned int unixTime() const
Time in seconds since January 1, 1970.
Definition: Timestamp.h:46
unsigned long long TimeValue_t
Definition: Timestamp.h:28
unsigned int timeLow_
Definition: Timestamp.h:115
bool operator==(Timestamp const &iRHS) const
Definition: Timestamp.h:67
static const TimeValue_t kLowMask
Definition: Timestamp.h:32
TimeValue_t value() const
Definition: Timestamp.h:56