CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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 {
32 {
33 
34  public:
35  IOVSyncValue();
36  //virtual ~IOVSyncValue();
37  explicit IOVSyncValue(const EventID& iID);
38  explicit IOVSyncValue(const Timestamp& iTime);
39  IOVSyncValue(const EventID& iID, const Timestamp& iTime);
40 
41  // ---------- const member functions ---------------------
42  const EventID& eventID() const { return eventID_;}
44  const Timestamp& time() const {return time_; }
45 
46  bool operator==(const IOVSyncValue& iRHS) const {
47  return comparable(iRHS) && doOp<std::equal_to>(iRHS);
48  }
49  bool operator!=(const IOVSyncValue& iRHS) const {
50  return (!comparable(iRHS)) || doOp<std::not_equal_to>(iRHS);
51  }
52 
53  bool operator<(const IOVSyncValue& iRHS) const {
54  return doOp<std::less>(iRHS);
55  }
56  bool operator<=(const IOVSyncValue& iRHS) const {
57  return doOp<std::less_equal>(iRHS);
58  }
59  bool operator>(const IOVSyncValue& iRHS) const {
60  return doOp<std::greater>(iRHS);
61  }
62  bool operator>=(const IOVSyncValue& iRHS) const {
63  return doOp<std::greater_equal>(iRHS);
64  }
65 
69  bool comparable(const IOVSyncValue& iOther) const {
70  return (haveID_==iOther.haveID_) || (haveTime_==iOther.haveTime_);
71  }
72 
73  // ---------- static member functions --------------------
74  static const IOVSyncValue& invalidIOVSyncValue();
75  static const IOVSyncValue& endOfTime();
76  static const IOVSyncValue& beginOfTime();
77 
78  // ---------- member functions ---------------------------
79 
80  private:
81  //IOVSyncValue(const IOVSyncValue&); // stop default
82 
83  //const IOVSyncValue& operator=(const IOVSyncValue&); // stop default
84  void throwInvalidComparison() const;
85  template< template <typename> class Op >
86  bool doOp(const IOVSyncValue& iRHS) const {
87  bool returnValue = false;
88  if(haveID_ && iRHS.haveID_) {
90  Op<EventID> op;
91  returnValue = op(eventID_, iRHS.eventID_);
92  } else {
93  if(iRHS.eventID_.run() == eventID_.run()) {
94  Op<LuminosityBlockNumber_t> op;
95  returnValue = op(luminosityBlockNumber(), iRHS.luminosityBlockNumber());
96  } else {
97  Op<RunNumber_t> op;
98  returnValue = op(eventID_.run(), iRHS.eventID_.run());
99  }
100  }
101 
102  } else if (haveTime_ && iRHS.haveTime_) {
103  Op<Timestamp> op;
104  returnValue = op(time_, iRHS.time_);
105  } else {
106  //error
108  }
109  return returnValue;
110  }
111 
112  // ---------- member data --------------------------------
115  bool haveID_;
116  bool haveTime_;
117 };
118 
119 }
120 
121 #endif
RunNumber_t run() const
Definition: EventID.h:39
bool doOp(const IOVSyncValue &iRHS) const
Definition: IOVSyncValue.h:86
const EventID & eventID() const
Definition: IOVSyncValue.h:42
static const IOVSyncValue & endOfTime()
Definition: IOVSyncValue.cc:97
LuminosityBlockNumber_t luminosityBlock() const
Definition: EventID.h:40
unsigned int LuminosityBlockNumber_t
bool operator>(const IOVSyncValue &iRHS) const
Definition: IOVSyncValue.h:59
void throwInvalidComparison() const
Definition: IOVSyncValue.cc:83
static const IOVSyncValue & beginOfTime()
bool operator<(const IOVSyncValue &iRHS) const
Definition: IOVSyncValue.h:53
LuminosityBlockNumber_t luminosityBlockNumber() const
Definition: IOVSyncValue.h:43
bool operator<=(const IOVSyncValue &iRHS) const
Definition: IOVSyncValue.h:56
bool operator>=(const IOVSyncValue &iRHS) const
Definition: IOVSyncValue.h:62
bool operator==(const IOVSyncValue &iRHS) const
Definition: IOVSyncValue.h:46
const Timestamp & time() const
Definition: IOVSyncValue.h:44
bool operator!=(const IOVSyncValue &iRHS) const
Definition: IOVSyncValue.h:49
bool comparable(const IOVSyncValue &iOther) const
Definition: IOVSyncValue.h:69
static const IOVSyncValue & invalidIOVSyncValue()
Definition: IOVSyncValue.cc:92