LArSoft  v06_85_00
Liquid Argon Software toolkit - http://larsoft.org/
Timestamp.h
Go to the documentation of this file.
1 #ifndef canvas_Persistency_Provenance_Timestamp_h
2 #define canvas_Persistency_Provenance_Timestamp_h
3 
4 #include <cstdint>
5 
6 namespace art {
7  using TimeValue_t = std::uint64_t;
8  class Timestamp;
9 }
10 
12 public:
13  constexpr Timestamp(TimeValue_t const iValue)
14  : timeLow_{static_cast<std::uint32_t>(lowMask() & iValue)}
15  , timeHigh_{static_cast<std::uint32_t>(iValue >> 32)}
16  {}
17 
18  constexpr Timestamp()
21  {}
22 
23  constexpr TimeValue_t
24  value() const
25  {
26  return (static_cast<std::uint64_t>(timeHigh_) << 32) | timeLow_;
27  }
28 
29  constexpr std::uint32_t
30  timeLow() const
31  {
32  return timeLow_;
33  }
34  constexpr std::uint32_t
35  timeHigh() const
36  {
37  return timeHigh_;
38  }
39 
40  // ---------- const member functions ---------------------
41  constexpr bool
42  operator==(Timestamp const& iRHS) const
43  {
44  return timeHigh_ == iRHS.timeHigh_ && timeLow_ == iRHS.timeLow_;
45  }
46 
47  constexpr bool
48  operator!=(Timestamp const& iRHS) const
49  {
50  return !(*this == iRHS);
51  }
52 
53  constexpr bool
54  operator<(Timestamp const& iRHS) const
55  {
56  return timeHigh_ == iRHS.timeHigh_ ? timeLow_ < iRHS.timeLow_ :
57  timeHigh_ < iRHS.timeHigh_;
58  }
59 
60  constexpr bool
61  operator<=(Timestamp const& iRHS) const
62  {
63  return timeHigh_ == iRHS.timeHigh_ ? timeLow_ <= iRHS.timeLow_ :
64  timeHigh_ <= iRHS.timeHigh_;
65  }
66 
67  constexpr bool
68  operator>(Timestamp const& iRHS) const
69  {
70  return timeHigh_ == iRHS.timeHigh_ ? timeLow_ > iRHS.timeLow_ :
71  timeHigh_ > iRHS.timeHigh_;
72  }
73 
74  constexpr bool
75  operator>=(Timestamp const& iRHS) const
76  {
77  return timeHigh_ == iRHS.timeHigh_ ? timeLow_ >= iRHS.timeLow_ :
78  timeHigh_ >= iRHS.timeHigh_;
79  }
80 
81  // ---------- static member functions --------------------
82  static constexpr Timestamp
84  {
85  return Timestamp{0};
86  }
87  static constexpr Timestamp
89  {
90  return Timestamp(-1);
91  }
92  static constexpr Timestamp
94  {
95  return Timestamp{1};
96  }
97 
98 private:
99  std::uint32_t timeLow_;
100  std::uint32_t timeHigh_;
101 
102  static constexpr TimeValue_t
104  {
105  return 0xFFFFFFFF;
106  }
107 };
108 #endif /* canvas_Persistency_Provenance_Timestamp_h */
109 
110 // Local Variables:
111 // mode: c++
112 // End:
constexpr std::uint32_t timeLow() const
Definition: Timestamp.h:30
constexpr bool operator!=(Timestamp const &iRHS) const
Definition: Timestamp.h:48
static constexpr Timestamp endOfTime()
Definition: Timestamp.h:88
constexpr std::uint32_t timeHigh() const
Definition: Timestamp.h:35
constexpr bool operator<=(Timestamp const &iRHS) const
Definition: Timestamp.h:61
static constexpr Timestamp beginOfTime()
Definition: Timestamp.h:93
constexpr bool operator<(Timestamp const &iRHS) const
Definition: Timestamp.h:54
constexpr TimeValue_t value() const
Definition: Timestamp.h:24
std::uint32_t timeHigh_
Definition: Timestamp.h:100
constexpr bool operator>(Timestamp const &iRHS) const
Definition: Timestamp.h:68
static constexpr TimeValue_t lowMask()
Definition: Timestamp.h:103
static constexpr Timestamp invalidTimestamp()
Definition: Timestamp.h:83
std::uint64_t TimeValue_t
Definition: Timestamp.h:7
constexpr bool operator==(Timestamp const &iRHS) const
Definition: Timestamp.h:42
HLT enums.
constexpr bool operator>=(Timestamp const &iRHS) const
Definition: Timestamp.h:75
constexpr Timestamp(TimeValue_t const iValue)
Definition: Timestamp.h:13
std::uint32_t timeLow_
Definition: Timestamp.h:99
constexpr Timestamp()
Definition: Timestamp.h:18