File indexing completed on 2025-02-14 03:16:31
0001
0002 #ifndef FWCore_Framework_EventSetupRecordProvider_h
0003 #define FWCore_Framework_EventSetupRecordProvider_h
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022 #include "FWCore/Framework/interface/EventSetupRecordKey.h"
0023 #include "FWCore/Framework/interface/EventSetupRecordImpl.h"
0024 #include "FWCore/Framework/interface/ValidityInterval.h"
0025 #include "FWCore/Utilities/interface/get_underlying_safe.h"
0026 #include "FWCore/Utilities/interface/propagate_const.h"
0027
0028
0029 #include <map>
0030 #include <memory>
0031 #include <set>
0032 #include <unordered_set>
0033 #include <vector>
0034
0035
0036 namespace edm {
0037 class ActivityRegistry;
0038 class EventSetupImpl;
0039 class EventSetupRecordIntervalFinder;
0040
0041 namespace eventsetup {
0042 struct ComponentDescription;
0043 class DataKey;
0044 class ESProductResolverProvider;
0045 class ESRecordsToProductResolverIndices;
0046 class EventSetupProvider;
0047 class EventSetupRecordImpl;
0048 class ParameterSetIDHolder;
0049
0050 class EventSetupRecordProvider {
0051 public:
0052 enum class IntervalStatus { NotInitializedForSyncValue, Invalid, NewInterval, UpdateIntervalEnd, SameInterval };
0053
0054 using DataToPreferredProviderMap = std::map<DataKey, ComponentDescription>;
0055
0056 EventSetupRecordProvider(EventSetupRecordKey const& iKey,
0057 ActivityRegistry const*,
0058 unsigned int nConcurrentIOVs = 1);
0059
0060 EventSetupRecordProvider(EventSetupRecordProvider const&) = delete;
0061 EventSetupRecordProvider const& operator=(EventSetupRecordProvider const&) = delete;
0062
0063
0064
0065 unsigned int nConcurrentIOVs() const { return nConcurrentIOVs_; }
0066
0067 ValidityInterval const& validityInterval() const { return validityInterval_; }
0068 EventSetupRecordKey const& key() const { return key_; }
0069
0070
0071
0072
0073 EventSetupRecordImpl const& firstRecordImpl() const;
0074
0075
0076 std::set<EventSetupRecordKey> dependentRecords() const;
0077
0078
0079 std::set<ComponentDescription> resolverProviderDescriptions() const;
0080
0081
0082 std::vector<DataKey> registeredDataKeys() const;
0083
0084 std::vector<ComponentDescription const*> componentsForRegisteredDataKeys() const;
0085 std::vector<unsigned int> produceMethodIDsForRegisteredDataKeys() const;
0086
0087
0088
0089
0090 std::shared_ptr<ESProductResolverProvider> resolverProvider(ComponentDescription const&);
0091
0092
0093 std::shared_ptr<ESProductResolverProvider> resolverProvider(ParameterSetIDHolder const&);
0094
0095 void resetProductResolverProvider(ParameterSetIDHolder const&, std::shared_ptr<ESProductResolverProvider> const&);
0096
0097 void add(std::shared_ptr<ESProductResolverProvider>);
0098
0099 void addFinder(std::shared_ptr<EventSetupRecordIntervalFinder>);
0100
0101
0102 void setValidityInterval_forTesting(ValidityInterval const&);
0103
0104
0105
0106
0107
0108
0109 void initializeForNewIOV(unsigned int iovIndex, unsigned long long cacheIdentifier);
0110
0111
0112
0113
0114
0115
0116
0117 void continueIOV(bool newEventSetupImpl);
0118
0119
0120
0121
0122 void endIOV(unsigned int iovIndex);
0123
0124
0125
0126
0127
0128
0129 void initializeForNewSyncValue();
0130
0131 bool doWeNeedToWaitForIOVsToFinish(IOVSyncValue const&) const;
0132
0133
0134
0135
0136 bool setValidityIntervalFor(IOVSyncValue const&);
0137
0138 bool newIntervalForAnySubProcess() const { return newIntervalForAnySubProcess_; }
0139 void setNewIntervalForAnySubProcess(bool value) { newIntervalForAnySubProcess_ = value; }
0140
0141
0142 void setDependentProviders(std::vector<std::shared_ptr<EventSetupRecordProvider>> const&);
0143
0144
0145
0146 void usePreferred(DataToPreferredProviderMap const&);
0147
0148
0149 void resetResolvers();
0150
0151 std::shared_ptr<EventSetupRecordIntervalFinder const> finder() const { return get_underlying_safe(finder_); }
0152 std::shared_ptr<EventSetupRecordIntervalFinder>& finder() { return get_underlying_safe(finder_); }
0153
0154 void getReferencedESProducers(
0155 std::map<EventSetupRecordKey, std::vector<ComponentDescription const*>>& referencedESProducers) const;
0156
0157 void fillReferencedDataKeys(std::map<DataKey, ComponentDescription const*>& referencedDataKeys) const;
0158
0159 void resetRecordToResolverPointers(DataToPreferredProviderMap const& iMap);
0160
0161 void setEventSetupImpl(EventSetupImpl* value) { eventSetupImpl_ = value; }
0162
0163 IntervalStatus intervalStatus() const { return intervalStatus_; }
0164
0165 void fillAllESProductResolverProviders(std::vector<ESProductResolverProvider const*>&,
0166 std::unordered_set<unsigned int>& componentIDs) const;
0167
0168 void updateLookup(ESRecordsToProductResolverIndices const&);
0169
0170 protected:
0171 void addResolversToRecordHelper(edm::propagate_const<std::shared_ptr<ESProductResolverProvider>>& dpp,
0172 DataToPreferredProviderMap const& mp) {
0173 addResolversToRecord(get_underlying_safe(dpp), mp);
0174 }
0175 void addResolversToRecord(std::shared_ptr<ESProductResolverProvider>, DataToPreferredProviderMap const&);
0176
0177 std::shared_ptr<EventSetupRecordIntervalFinder> swapFinder(std::shared_ptr<EventSetupRecordIntervalFinder> iNew) {
0178 std::swap(iNew, finder());
0179 return iNew;
0180 }
0181
0182 private:
0183
0184 const EventSetupRecordKey key_;
0185
0186
0187
0188
0189 ValidityInterval validityInterval_;
0190
0191 EventSetupImpl* eventSetupImpl_ = nullptr;
0192
0193 std::vector<EventSetupRecordImpl> recordImpls_;
0194 EventSetupRecordImpl const* recordImpl_ = nullptr;
0195
0196 edm::propagate_const<std::shared_ptr<EventSetupRecordIntervalFinder>> finder_;
0197 std::vector<edm::propagate_const<std::shared_ptr<ESProductResolverProvider>>> providers_;
0198 std::unique_ptr<std::vector<edm::propagate_const<std::shared_ptr<EventSetupRecordIntervalFinder>>>>
0199 multipleFinders_;
0200
0201 const unsigned int nConcurrentIOVs_;
0202 IntervalStatus intervalStatus_ = IntervalStatus::NotInitializedForSyncValue;
0203 bool newIntervalForAnySubProcess_ = false;
0204 bool hasNonconcurrentFinder_ = false;
0205 };
0206 }
0207 }
0208 #endif