Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2023-10-25 09:46:49

0001 #ifndef FWCore_Framework_ESRecordsToProductResolverIndices_h
0002 #define FWCore_Framework_ESRecordsToProductResolverIndices_h
0003 // -*- C++ -*-
0004 //
0005 // Package:     Framework
0006 // Class  :     ESRecordsToProductResolverIndices
0007 //
0008 /**\class ESRecordsToProductResolverIndices ESRecordsToProductResolverIndices.h FWCore/Framework/interface/ESRecordsToProductResolverIndices.h
0009 
0010  Description: Key used to identify data within a EventSetupRecord
0011 
0012  Usage:
0013     <usage>
0014 
0015 */
0016 //
0017 // Author:      Chris Jones
0018 // Created:     Tues Feb 12 14:31:03 EST 2019
0019 //
0020 
0021 // system include files
0022 #include <limits>
0023 #include <vector>
0024 
0025 // user include files
0026 #include "FWCore/Framework/interface/DataKey.h"
0027 #include "FWCore/Framework/interface/EventSetupRecordKey.h"
0028 #include "FWCore/Framework/interface/ESTagGetter.h"
0029 #include "FWCore/Utilities/interface/ESIndices.h"
0030 
0031 // forward declarations
0032 namespace edm::eventsetup {
0033   struct ComponentDescription;
0034 
0035   class ESRecordsToProductResolverIndices {
0036   public:
0037     ESRecordsToProductResolverIndices(std::vector<EventSetupRecordKey> iRecords);
0038 
0039     // ---------- const member functions ---------------------
0040     ///If the index is not found, returns missingResolverIndex()
0041     ESResolverIndex indexInRecord(EventSetupRecordKey const& iRK, DataKey const& iDK) const noexcept;
0042 
0043     ComponentDescription const* component(EventSetupRecordKey const& iRK, DataKey const& iDK) const noexcept;
0044 
0045     ///Returns ESTagGetter for all products matching the type iTT for record iRK
0046     ESTagGetter makeTagGetter(EventSetupRecordKey const& iRK, TypeTag const& iTT) const;
0047 
0048     static constexpr ESResolverIndex missingResolverIndex() noexcept {
0049       return ESResolverIndex{std::numeric_limits<int>::max()};
0050     }
0051     static constexpr ESRecordIndex missingRecordIndex() noexcept {
0052       return ESRecordIndex{ESRecordIndex::invalidValue()};
0053     }
0054 
0055     ESRecordIndex recordIndexFor(EventSetupRecordKey const& iRK) const noexcept;
0056 
0057     std::pair<std::vector<DataKey>::const_iterator, std::vector<DataKey>::const_iterator> keysForRecord(
0058         EventSetupRecordKey const& iRK) const noexcept;
0059     ///The sorted list of keys
0060     std::vector<EventSetupRecordKey> recordKeys() const noexcept { return recordKeys_; }
0061 
0062     // ---------- member functions ---------------------------
0063     ///This should be called for all records in the list passed to the constructor and
0064     /// in the same order as the list.
0065     unsigned int dataKeysInRecord(unsigned int iRecordIndex,
0066                                   EventSetupRecordKey const& iRecord,
0067                                   std::vector<DataKey> const& iDataKeys,
0068                                   std::vector<ComponentDescription const*> const& iComponents);
0069 
0070   private:
0071     // ---------- member data --------------------------------
0072     std::vector<EventSetupRecordKey> recordKeys_;
0073     //for each item in recordKeys_ this holds the index to the first
0074     // DataKey for that item in dataKeys_
0075     // recordOffset_ is 1 size larger than recordKeys_ with the
0076     // last entry being dataKeys_.size()
0077     std::vector<unsigned int> recordOffsets_;
0078     std::vector<DataKey> dataKeys_;
0079     std::vector<ComponentDescription const*> components_;
0080   };
0081 
0082 }  // namespace edm::eventsetup
0083 #endif