Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:12:10

0001 // -*- C++ -*-
0002 //
0003 // Package:     Framework
0004 // Class  :     EventSetupRecordIntervalFinder
0005 //
0006 // Implementation:
0007 //     <Notes on implementation>
0008 //
0009 // Author:      Chris Jones
0010 // Created:     Wed Mar 30 14:27:26 EST 2005
0011 //
0012 
0013 #include "FWCore/Framework/interface/EventSetupRecordIntervalFinder.h"
0014 #include "FWCore/Utilities/interface/Likely.h"
0015 #include <cassert>
0016 #include <mutex>
0017 
0018 using namespace edm::eventsetup;
0019 namespace edm {
0020 
0021   EventSetupRecordIntervalFinder::~EventSetupRecordIntervalFinder() noexcept(false) {}
0022 
0023   const ValidityInterval& EventSetupRecordIntervalFinder::findIntervalFor(const EventSetupRecordKey& iKey,
0024                                                                           const IOVSyncValue& iInstance) {
0025     Intervals::iterator itFound = intervals_.find(iKey);
0026     assert(itFound != intervals_.end());
0027     if (!itFound->second.validFor(iInstance)) {
0028       if LIKELY (iInstance != IOVSyncValue::invalidIOVSyncValue()) {
0029         setIntervalFor(iKey, iInstance, itFound->second);
0030       } else {
0031         itFound->second = ValidityInterval::invalidInterval();
0032       }
0033     }
0034     return itFound->second;
0035   }
0036 
0037   void EventSetupRecordIntervalFinder::resetInterval(const eventsetup::EventSetupRecordKey& iKey) {
0038     Intervals::iterator itFound = intervals_.find(iKey);
0039     assert(itFound != intervals_.end());
0040     itFound->second = ValidityInterval{};
0041     doResetInterval(iKey);
0042   }
0043 
0044   void EventSetupRecordIntervalFinder::findingRecordWithKey(const EventSetupRecordKey& iKey) {
0045     intervals_.insert(Intervals::value_type(iKey, ValidityInterval()));
0046   }
0047 
0048   void EventSetupRecordIntervalFinder::doResetInterval(const eventsetup::EventSetupRecordKey&) {}
0049 
0050   bool EventSetupRecordIntervalFinder::isConcurrentFinder() const { return false; }
0051 
0052   bool EventSetupRecordIntervalFinder::isNonconcurrentAndIOVNeedsUpdate(const eventsetup::EventSetupRecordKey& iKey,
0053                                                                         const IOVSyncValue& iTime) const {
0054     if (!isConcurrentFinder()) {
0055       if (iTime == IOVSyncValue::invalidIOVSyncValue()) {
0056         return true;
0057       }
0058       Intervals::const_iterator itFound = intervals_.find(iKey);
0059       assert(itFound != intervals_.end());
0060       return !itFound->second.validFor(iTime);
0061     }
0062     return false;
0063   }
0064 
0065   void EventSetupRecordIntervalFinder::delaySettingRecords() {}
0066 
0067   std::set<EventSetupRecordKey> EventSetupRecordIntervalFinder::findingForRecords() const {
0068     if (intervals_.empty()) {
0069       //we are delaying our reading
0070       const_cast<EventSetupRecordIntervalFinder*>(this)->delaySettingRecords();
0071     }
0072 
0073     std::set<EventSetupRecordKey> returnValue;
0074 
0075     for (Intervals::const_iterator itEntry = intervals_.begin(), itEntryEnd = intervals_.end(); itEntry != itEntryEnd;
0076          ++itEntry) {
0077       returnValue.insert(returnValue.end(), itEntry->first);
0078     }
0079     return returnValue;
0080   }
0081 }  // namespace edm