CMS 3D CMS Logo

IOVSyncValue.h
Go to the documentation of this file.
1 #ifndef Framework_IOVSyncValue_h
2 #define Framework_IOVSyncValue_h
3 // -*- C++ -*-
4 //
5 // Package: Framework
6 // Class : IOVSyncValue
7 //
16 //
17 // Original Author: Chris Jones
18 // Created: Wed Aug 3 18:35:24 EDT 2005
19 //
20 
21 // system include files
22 #include <functional>
23 
24 // user include files
27 
28 // forward declarations
29 
30 namespace edm {
31  class IOVSyncValue {
32  public:
33  IOVSyncValue();
34  //virtual ~IOVSyncValue();
35  explicit IOVSyncValue(const EventID& iID);
36  explicit IOVSyncValue(const Timestamp& iTime);
37  IOVSyncValue(const EventID& iID, const Timestamp& iTime);
38 
39  // ---------- const member functions ---------------------
40  const EventID& eventID() const { return eventID_; }
42  const Timestamp& time() const { return time_; }
43 
44  bool operator==(const IOVSyncValue& iRHS) const { return comparable(iRHS) && doOp<std::equal_to>(iRHS); }
45  bool operator!=(const IOVSyncValue& iRHS) const { return (!comparable(iRHS)) || doOp<std::not_equal_to>(iRHS); }
46 
47  bool operator<(const IOVSyncValue& iRHS) const { return doOp<std::less>(iRHS); }
48  bool operator<=(const IOVSyncValue& iRHS) const { return doOp<std::less_equal>(iRHS); }
49  bool operator>(const IOVSyncValue& iRHS) const { return doOp<std::greater>(iRHS); }
50  bool operator>=(const IOVSyncValue& iRHS) const { return doOp<std::greater_equal>(iRHS); }
51 
55  bool comparable(const IOVSyncValue& iOther) const {
56  return (haveID_ == iOther.haveID_) || (haveTime_ == iOther.haveTime_);
57  }
58 
59  // ---------- static member functions --------------------
60  static const IOVSyncValue& invalidIOVSyncValue();
61  static const IOVSyncValue& endOfTime();
62  static const IOVSyncValue& beginOfTime();
63 
64  // ---------- member functions ---------------------------
65 
66  private:
67  //IOVSyncValue(const IOVSyncValue&); // stop default
68 
69  //const IOVSyncValue& operator=(const IOVSyncValue&); // stop default
70  void throwInvalidComparison() const;
71  template <template <typename> class Op>
72  bool doOp(const IOVSyncValue& iRHS) const {
73  bool returnValue = false;
74  if (haveID_ && iRHS.haveID_) {
75  if (luminosityBlockNumber() == 0 || iRHS.luminosityBlockNumber() == 0 ||
77  Op<EventID> op;
78  returnValue = op(eventID_, iRHS.eventID_);
79  } else {
80  if (iRHS.eventID_.run() == eventID_.run()) {
81  Op<LuminosityBlockNumber_t> op;
82  returnValue = op(luminosityBlockNumber(), iRHS.luminosityBlockNumber());
83  } else {
84  Op<RunNumber_t> op;
85  returnValue = op(eventID_.run(), iRHS.eventID_.run());
86  }
87  }
88 
89  } else if (haveTime_ && iRHS.haveTime_) {
90  Op<Timestamp> op;
91  returnValue = op(time_, iRHS.time_);
92  } else {
93  //error
95  }
96  return returnValue;
97  }
98 
99  // ---------- member data --------------------------------
102  bool haveID_;
103  bool haveTime_;
104  };
105 
106 } // namespace edm
107 
108 #endif
RunNumber_t run() const
Definition: EventID.h:39
bool doOp(const IOVSyncValue &iRHS) const
Definition: IOVSyncValue.h:72
const EventID & eventID() const
Definition: IOVSyncValue.h:40
static const IOVSyncValue & endOfTime()
Definition: IOVSyncValue.cc:82
LuminosityBlockNumber_t luminosityBlock() const
Definition: EventID.h:40
unsigned int LuminosityBlockNumber_t
bool operator>(const IOVSyncValue &iRHS) const
Definition: IOVSyncValue.h:49
void throwInvalidComparison() const
Definition: IOVSyncValue.cc:69
static const IOVSyncValue & beginOfTime()
Definition: IOVSyncValue.cc:88
bool operator<(const IOVSyncValue &iRHS) const
Definition: IOVSyncValue.h:47
LuminosityBlockNumber_t luminosityBlockNumber() const
Definition: IOVSyncValue.h:41
bool operator<=(const IOVSyncValue &iRHS) const
Definition: IOVSyncValue.h:48
bool operator>=(const IOVSyncValue &iRHS) const
Definition: IOVSyncValue.h:50
HLT enums.
bool operator==(const IOVSyncValue &iRHS) const
Definition: IOVSyncValue.h:44
const Timestamp & time() const
Definition: IOVSyncValue.h:42
bool operator!=(const IOVSyncValue &iRHS) const
Definition: IOVSyncValue.h:45
bool comparable(const IOVSyncValue &iOther) const
Definition: IOVSyncValue.h:55
static const IOVSyncValue & invalidIOVSyncValue()
Definition: IOVSyncValue.cc:78