Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2025-02-14 03:16:31

0001 // -*- C++ -*-
0002 #ifndef FWCore_Framework_ESRecordsToProductResolverIndices_h
0003 #define FWCore_Framework_ESRecordsToProductResolverIndices_h
0004 //
0005 // Package:     Framework
0006 // Class  :     ESRecordsToProductResolverIndices
0007 //
0008 /**\class edm::eventsetup::ESRecordsToProductResolverIndices
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 <tuple>
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() = default;
0038     ESRecordsToProductResolverIndices(std::vector<EventSetupRecordKey> iRecords);
0039 
0040     // ---------- const member functions ---------------------
0041     ///If the index is not found, returns ESResolverIndex::noResolverConfigured()
0042     ESResolverIndex indexInRecord(EventSetupRecordKey const& iRK, DataKey const& iDK) const noexcept;
0043 
0044     ComponentDescription const* component(EventSetupRecordKey const& iRK, DataKey const& iDK) const noexcept;
0045 
0046     std::tuple<ComponentDescription const*, unsigned int> componentAndProduceMethodID(EventSetupRecordKey const&,
0047                                                                                       ESResolverIndex) const noexcept;
0048 
0049     ///Returns ESTagGetter for all products matching the type iTT for record iRK
0050     ESTagGetter makeTagGetter(EventSetupRecordKey const& iRK, TypeTag const& iTT) const;
0051 
0052     static constexpr ESRecordIndex missingRecordIndex() noexcept {
0053       return ESRecordIndex{ESRecordIndex::invalidValue()};
0054     }
0055 
0056     ESRecordIndex recordIndexFor(EventSetupRecordKey const& iRK) const noexcept;
0057 
0058     std::pair<std::vector<DataKey>::const_iterator, std::vector<DataKey>::const_iterator> keysForRecord(
0059         EventSetupRecordKey const& iRK) const noexcept;
0060     ///The sorted list of keys
0061     std::vector<EventSetupRecordKey> recordKeys() const noexcept { return recordKeys_; }
0062 
0063     // ---------- member functions ---------------------------
0064     ///This should be called for all records in the list passed to the constructor and
0065     /// in the same order as the list.
0066     unsigned int dataKeysInRecord(unsigned int iRecordIndex,
0067                                   EventSetupRecordKey const& iRecord,
0068                                   std::vector<DataKey> const& iDataKeys,
0069                                   std::vector<ComponentDescription const*> const& iComponents,
0070                                   std::vector<unsigned int> const& iProduceMethodIDs);
0071 
0072   private:
0073     // ---------- member data --------------------------------
0074     std::vector<EventSetupRecordKey> recordKeys_;
0075     //for each item in recordKeys_ this holds the index to the first
0076     // DataKey for that item in dataKeys_
0077     // recordOffset_ is 1 size larger than recordKeys_ with the
0078     // last entry being dataKeys_.size()
0079     std::vector<unsigned int> recordOffsets_;
0080     std::vector<DataKey> dataKeys_;
0081     std::vector<ComponentDescription const*> components_;
0082     std::vector<unsigned int> produceMethodIDs_;
0083   };
0084 
0085 }  // namespace edm::eventsetup
0086 #endif