LArSoft  v07_13_02
Liquid Argon Software toolkit - http://larsoft.org/
RunID.h
Go to the documentation of this file.
1 #ifndef canvas_Persistency_Provenance_RunID_h
2 #define canvas_Persistency_Provenance_RunID_h
3 
4 //
5 // A RunID represents a unique period of operation of the data
6 // acquisition system, which we call a "run".
7 //
8 // Each RunID contains a fixed-size unsigned integer, the run number.
9 //
10 
12 #include <cstdint>
13 #include <iosfwd>
14 
15 namespace art {
16  class RunID;
17 
18  std::ostream& operator<<(std::ostream& os, art::RunID const& iID);
19 }
20 
21 class art::RunID {
22 public:
23  constexpr RunID();
24  explicit RunID(RunNumber_t i);
25 
26  RunNumber_t run() const;
27 
28  bool isValid() const;
29  bool isFlush() const;
30 
31  RunID next() const;
32  RunID previous() const;
33 
34  static RunID maxRun();
35  static RunID firstRun();
36  static constexpr RunID flushRun();
37 
38  // Comparison operators.
39  bool operator==(RunID const& other) const;
40  bool operator!=(RunID const& other) const;
41  bool operator<(RunID const& other) const;
42  bool operator<=(RunID const& other) const;
43  bool operator>(RunID const& other) const;
44  bool operator>=(RunID const& other) const;
45 
46  friend std::ostream& operator<<(std::ostream& os, RunID const& iID);
47 
48 private:
49  struct FlushFlag {
50  };
51 
52  explicit constexpr RunID(FlushFlag);
53 
56 };
57 
58 inline constexpr art::RunID::RunID() : run_(IDNumber<Level::Run>::invalid()) {}
59 
61 
62 inline art::RunNumber_t
64 {
65  return run_;
66 }
67 
68 inline bool
70 {
71  return (run_ != IDNumber<Level::Run>::invalid());
72 }
73 
74 inline bool
76 {
78 }
79 
81 
82 inline art::RunID
84 {
85  if (!isValid()) {
87  << "cannot increment invalid run number.";
88  } else if (run_ == IDNumber<Level::Run>::max_natural()) {
90  << "cannot increment maximum run number.";
91  }
92  return RunID(run_ + 1);
93 }
94 
95 inline art::RunID
97 {
98  if (!isValid()) {
100  << "cannot decrement minimum run number.";
101  } else if (run_ == IDNumber<Level::Run>::max_natural()) {
103  << "cannot increment maximum run number.";
104  }
105  return RunID(run_ - 1);
106 }
107 
108 inline art::RunID
110 {
112 }
113 
114 inline art::RunID
116 {
118 }
119 
120 inline constexpr art::RunID
122 {
123  return RunID(FlushFlag());
124 }
125 
126 // Comparison operators.
127 inline bool
129 {
130  return other.run_ == run_;
131 }
132 
133 inline bool
135 {
136  return !(*this == other);
137 }
138 
140 
141 inline bool
143 {
145  return op(run_, other.run_);
146 }
147 
148 inline bool
150 {
151  return (*this < other) || (*this == other);
152 }
153 
154 inline bool
156 {
157  return (other < *this);
158 }
159 
160 inline bool
162 {
163  return !(*this < other);
164 }
165 
166 inline art::RunNumber_t
168 {
169  if (r == IDNumber<Level::Run>::invalid() ||
170  (r >= IDNumber<Level::Run>::first() &&
172  return r;
173  } else {
175  << "Attempt to construct RunID with an invalid number.\n"
176  << "Maybe you want RunID::flushRun()?\n";
177  }
178 }
179 
180 inline constexpr art::RunID::RunID(FlushFlag)
182 {}
183 
184 #endif /* canvas_Persistency_Provenance_RunID_h */
185 
186 // Local Variables:
187 // mode: c++
188 // End:
std::ostream & operator<<(std::ostream &os, EDAnalyzer::Table< T > const &t)
Definition: EDAnalyzer.h:184
bool operator>=(RunID const &other) const
Definition: RunID.h:161
bool isFlush() const
Definition: RunID.h:75
static constexpr RunID flushRun()
Definition: RunID.h:121
RunID next() const
Definition: RunID.h:83
RunNumber_t inRangeOrInvalid(RunNumber_t r)
Definition: RunID.h:167
Level
Definition: Level.h:12
bool operator==(RunID const &other) const
Definition: RunID.h:128
RunNumber_t run() const
Definition: RunID.h:63
Definition: Run.h:30
bool operator!=(RunID const &other) const
Definition: RunID.h:134
static RunID maxRun()
Definition: RunID.h:109
bool operator>(RunID const &other) const
Definition: RunID.h:155
bool operator<(RunID const &other) const
Definition: RunID.h:142
RunNumber_t run_
Definition: RunID.h:55
RunID previous() const
Definition: RunID.h:96
cet::coded_exception< errors::ErrorCodes, ExceptionDetail::translate > Exception
Definition: Exception.h:66
bool operator<=(RunID const &other) const
Definition: RunID.h:149
bool isValid() const
Definition: RunID.h:69
HLT enums.
constexpr RunID()
Definition: RunID.h:58
static RunID firstRun()
Definition: RunID.h:115
friend std::ostream & operator<<(std::ostream &os, RunID const &iID)
IDNumber_t< Level::Run > RunNumber_t
Definition: IDNumber.h:119