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