CMS 3D CMS Logo

/data/doxygen/doxygen-1.7.3/gen/CMSSW_4_2_8/src/FWCore/Framework/src/IntersectingIOVRecordIntervalFinder.cc

Go to the documentation of this file.
00001 // -*- C++ -*-
00002 //
00003 // Package:     Framework
00004 // Class  :     IntersectingIOVRecordIntervalFinder
00005 // 
00006 // Implementation:
00007 //     <Notes on implementation>
00008 //
00009 // Original Author:  Chris Jones
00010 //         Created:  Tue Aug 19 13:20:41 EDT 2008
00011 // $Id: IntersectingIOVRecordIntervalFinder.cc,v 1.2 2008/09/03 13:41:51 chrjones Exp $
00012 //
00013 
00014 // system include files
00015 
00016 // user include files
00017 #include "FWCore/Framework/src/IntersectingIOVRecordIntervalFinder.h"
00018 namespace edm {
00019    namespace eventsetup {
00020 
00021 //
00022 // constants, enums and typedefs
00023 //
00024 
00025 //
00026 // static data member definitions
00027 //
00028 
00029 //
00030 // constructors and destructor
00031 //
00032 IntersectingIOVRecordIntervalFinder::IntersectingIOVRecordIntervalFinder(const EventSetupRecordKey& iKey)
00033 {
00034    findingRecordWithKey(iKey);
00035 }
00036 
00037 // IntersectingIOVRecordIntervalFinder::IntersectingIOVRecordIntervalFinder(const IntersectingIOVRecordIntervalFinder& rhs)
00038 // {
00039 //    // do actual copying here;
00040 // }
00041 
00042 IntersectingIOVRecordIntervalFinder::~IntersectingIOVRecordIntervalFinder()
00043 {
00044 }
00045 
00046 //
00047 // assignment operators
00048 //
00049 // const IntersectingIOVRecordIntervalFinder& IntersectingIOVRecordIntervalFinder::operator=(const IntersectingIOVRecordIntervalFinder& rhs)
00050 // {
00051 //   //An exception safe implementation is
00052 //   IntersectingIOVRecordIntervalFinder temp(rhs);
00053 //   swap(rhs);
00054 //
00055 //   return *this;
00056 // }
00057 
00058 //
00059 // member functions
00060 //
00061 void 
00062 IntersectingIOVRecordIntervalFinder::swapFinders(std::vector<boost::shared_ptr<EventSetupRecordIntervalFinder> >& iFinders)
00063 {
00064    finders_.swap(iFinders);
00065 }
00066 
00067 void 
00068 IntersectingIOVRecordIntervalFinder::setIntervalFor(const EventSetupRecordKey& iKey,
00069                                                     const IOVSyncValue& iTime, 
00070                                                     ValidityInterval& oInterval)
00071 {
00072    if(finders_.empty()) {
00073       oInterval = ValidityInterval::invalidInterval();
00074       return;
00075    }
00076    
00077    bool haveAValidRecord = false;
00078    bool haveUnknownEnding = false;
00079    ValidityInterval newInterval(IOVSyncValue::beginOfTime(), IOVSyncValue::endOfTime());
00080 
00081    for(std::vector<boost::shared_ptr<EventSetupRecordIntervalFinder> >::iterator it = finders_.begin(),
00082        itEnd = finders_.end(); it != itEnd; ++it) {
00083       ValidityInterval test = (*it)->findIntervalFor(iKey, iTime);
00084       if ( test != ValidityInterval::invalidInterval() ) {
00085          haveAValidRecord =true;
00086          if(newInterval.first() < test.first()) {
00087             newInterval.setFirst(test.first());
00088          }
00089          if(newInterval.last() > test.last()) {
00090             newInterval.setLast(test.last());
00091          }
00092          if(test.last() == IOVSyncValue::invalidIOVSyncValue()) {
00093             haveUnknownEnding=true;
00094          }
00095       } else {
00096          //if it is invalid then we must check on each new IOVSyncValue so that 
00097          // we can find the time when it is valid
00098          haveUnknownEnding=true;
00099       }
00100    }
00101    
00102    if(!haveAValidRecord) {
00103       //If no Finder has a valid time, then this record is also invalid for this time
00104       newInterval = ValidityInterval::invalidInterval();
00105    } else if(haveUnknownEnding) {
00106       newInterval.setLast(IOVSyncValue::invalidIOVSyncValue());
00107    }
00108    oInterval = newInterval;
00109 }
00110 
00111 //
00112 // const member functions
00113 //
00114 
00115 //
00116 // static member functions
00117 //
00118    }
00119 }