CMS 3D CMS Logo

IOVSyncValue.h

Go to the documentation of this file.
00001 #ifndef Framework_IOVSyncValue_h
00002 #define Framework_IOVSyncValue_h
00003 // -*- C++ -*-
00004 //
00005 // Package:     Framework
00006 // Class  :     IOVSyncValue
00007 // 
00016 //
00017 // Original Author:  Chris Jones
00018 //         Created:  Wed Aug  3 18:35:24 EDT 2005
00019 // $Id: IOVSyncValue.h,v 1.7 2008/08/11 22:51:44 chrjones Exp $
00020 //
00021 
00022 // system include files
00023 #include <functional>
00024 
00025 // user include files
00026 #include "DataFormats/Provenance/interface/EventID.h"
00027 #include "DataFormats/Provenance/interface/LuminosityBlockID.h"
00028 #include "DataFormats/Provenance/interface/Timestamp.h"
00029 
00030 // forward declarations
00031 
00032 namespace edm {
00033 class IOVSyncValue
00034 {
00035 
00036    public:
00037       IOVSyncValue();
00038       //virtual ~IOVSyncValue();
00039       explicit IOVSyncValue(const EventID& iID, LuminosityBlockNumber_t iLumi=0);
00040       explicit IOVSyncValue(const Timestamp& iTime);
00041       IOVSyncValue(const EventID& iID, LuminosityBlockNumber_t iLumi, const Timestamp& iID);
00042 
00043       // ---------- const member functions ---------------------
00044       const EventID& eventID() const { return eventID_;}
00045       LuminosityBlockNumber_t luminosityBlockNumber() const { return lumiID_;}
00046       const Timestamp& time() const {return time_; }
00047       
00048       bool operator==(const IOVSyncValue& iRHS) const {
00049          return doOp<std::equal_to>(iRHS);
00050       }
00051       bool operator!=(const IOVSyncValue& iRHS) const {
00052          return doOp<std::not_equal_to>(iRHS);
00053       }
00054       
00055       bool operator<(const IOVSyncValue& iRHS) const {
00056          return doOp<std::less>(iRHS);
00057       }
00058       bool operator<=(const IOVSyncValue& iRHS) const {
00059          return doOp<std::less_equal>(iRHS);
00060       }
00061       bool operator>(const IOVSyncValue& iRHS) const {
00062          return doOp<std::greater>(iRHS);
00063       }
00064       bool operator>=(const IOVSyncValue& iRHS) const {
00065          return doOp<std::greater_equal>(iRHS);
00066       }
00067       
00068       // ---------- static member functions --------------------
00069       static const IOVSyncValue& invalidIOVSyncValue();
00070       static const IOVSyncValue& endOfTime();
00071       static const IOVSyncValue& beginOfTime();
00072 
00073       // ---------- member functions ---------------------------
00074 
00075    private:
00076       //IOVSyncValue(const IOVSyncValue&); // stop default
00077 
00078       //const IOVSyncValue& operator=(const IOVSyncValue&); // stop default
00079       template< template <typename> class Op >
00080          bool doOp(const IOVSyncValue& iRHS) const {
00081             bool returnValue = false;
00082             if(haveID_ && iRHS.haveID_) {
00083                if(lumiID_==0 || iRHS.lumiID_==0 || lumiID_==iRHS.lumiID_) {
00084                   Op<EventID> op;
00085                   returnValue = op(eventID_, iRHS.eventID_);
00086                } else {
00087                   if(iRHS.eventID_.run() == eventID_.run()) {
00088                      Op<LuminosityBlockNumber_t> op;
00089                      returnValue = op(lumiID_, iRHS.lumiID_);
00090                   } else {
00091                      Op<RunNumber_t> op;
00092                      returnValue = op(eventID_.run(), iRHS.eventID_.run());
00093                   }
00094                }
00095 
00096             } else if (haveTime_ && iRHS.haveTime_) {
00097                Op<Timestamp> op;
00098                returnValue = op(time_, iRHS.time_);
00099             } else {
00100                //error
00101             }
00102             return returnValue;
00103          }
00104          
00105       // ---------- member data --------------------------------
00106       EventID eventID_;
00107       LuminosityBlockNumber_t lumiID_;
00108       Timestamp time_;
00109       bool haveID_;
00110       bool haveTime_;
00111 };
00112 
00113 }
00114 
00115 #endif

Generated on Tue Jun 9 17:35:42 2009 for CMSSW by  doxygen 1.5.4