File indexing completed on 2025-04-30 22:24:06
0001
0002 #ifndef FWCore_Framework_EventSetupRecordImpl_h
0003 #define FWCore_Framework_EventSetupRecordImpl_h
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027
0028
0029
0030
0031
0032
0033
0034
0035
0036
0037
0038 #include "FWCore/Framework/interface/FunctorESHandleExceptionFactory.h"
0039 #include "FWCore/Framework/interface/DataKey.h"
0040 #include "FWCore/Framework/interface/ValidityInterval.h"
0041 #include "FWCore/Framework/interface/EventSetupRecordKey.h"
0042 #include "FWCore/Concurrency/interface/WaitingTaskHolder.h"
0043 #include "FWCore/Utilities/interface/thread_safety_macros.h"
0044 #include "FWCore/Utilities/interface/propagate_const.h"
0045 #include "FWCore/Utilities/interface/ESIndices.h"
0046
0047
0048 #include <memory>
0049 #include <vector>
0050 #include <atomic>
0051 #include <cassert>
0052
0053
0054 namespace cms {
0055 class Exception;
0056 }
0057
0058 namespace edm {
0059
0060 class ActivityRegistry;
0061 class ESHandleExceptionFactory;
0062 class EventSetupImpl;
0063 class ServiceToken;
0064 class ESParentContext;
0065
0066 namespace eventsetup {
0067 struct ComponentDescription;
0068 class ESProductResolver;
0069
0070 class EventSetupRecordImpl {
0071 friend class EventSetupRecord;
0072
0073 public:
0074 EventSetupRecordImpl(const EventSetupRecordKey& iKey, ActivityRegistry const*, unsigned int iovIndex = 0);
0075 EventSetupRecordImpl(EventSetupRecordImpl const&) = delete;
0076 EventSetupRecordImpl const& operator=(EventSetupRecordImpl const&) = delete;
0077 EventSetupRecordImpl(EventSetupRecordImpl&&);
0078 EventSetupRecordImpl& operator=(EventSetupRecordImpl&&);
0079
0080 ValidityInterval validityInterval() const;
0081
0082
0083 void prefetchAsync(WaitingTaskHolder iTask,
0084 ESResolverIndex iResolverIndex,
0085 EventSetupImpl const*,
0086 ServiceToken const&,
0087 ESParentContext) const noexcept;
0088
0089
0090
0091
0092 bool wasGotten(DataKey const& aKey) const;
0093
0094
0095
0096
0097
0098 ComponentDescription const* providerDescription(DataKey const& aKey) const;
0099
0100 EventSetupRecordKey const& key() const { return key_; }
0101
0102
0103
0104
0105
0106
0107
0108
0109
0110
0111
0112 unsigned long long cacheIdentifier() const { return cacheIdentifier_; }
0113
0114 unsigned int iovIndex() const { return iovIndex_; }
0115
0116
0117 std::vector<DataKey> const& registeredDataKeys() const;
0118
0119 std::vector<ComponentDescription const*> componentsForRegisteredDataKeys() const;
0120
0121 std::vector<unsigned int> produceMethodIDsForRegisteredDataKeys() const;
0122
0123
0124 bool add(DataKey const& iKey, ESProductResolver* iResolver);
0125 void clearResolvers();
0126
0127
0128
0129
0130
0131
0132 void initializeForNewIOV(unsigned long long iCacheIdentifier, ValidityInterval const&, bool hasFinder);
0133
0134
0135
0136
0137
0138
0139 void setSafely(ValidityInterval const&) const;
0140
0141 void getESProducers(std::vector<ComponentDescription const*>& esproducers) const;
0142
0143 ESProductResolver const* find(DataKey const& aKey) const;
0144
0145 ActivityRegistry const* activityRegistry() const noexcept { return activityRegistry_; }
0146
0147 void addTraceInfoToCmsException(cms::Exception& iException,
0148 char const* iName,
0149 ComponentDescription const*,
0150 DataKey const&) const;
0151
0152 void invalidateResolvers();
0153 void resetIfTransientInResolvers();
0154
0155 private:
0156 void const* getFromResolverAfterPrefetch(ESResolverIndex iResolverIndex,
0157 bool iTransientAccessOnly,
0158 ComponentDescription const*& iDesc,
0159 DataKey const*& oGottenKey) const;
0160
0161 template <typename DataT>
0162 void getImplementation(DataT const*& iData,
0163 ESResolverIndex iResolverIndex,
0164 bool iTransientAccessOnly,
0165 ComponentDescription const*& oDesc,
0166 std::shared_ptr<ESHandleExceptionFactory>& whyFailedFactory) const {
0167 DataKey const* dataKey = nullptr;
0168 assert(iResolverIndex.value() > -1 and
0169 iResolverIndex.value() < static_cast<ESResolverIndex::Value_t>(keysForResolvers_.size()));
0170 void const* pValue = this->getFromResolverAfterPrefetch(iResolverIndex, iTransientAccessOnly, oDesc, dataKey);
0171 iData = reinterpret_cast<DataT const*>(pValue);
0172 }
0173
0174
0175
0176
0177
0178
0179
0180
0181
0182
0183 CMS_THREAD_SAFE mutable ValidityInterval validity_;
0184
0185 EventSetupRecordKey key_;
0186 std::vector<DataKey> keysForResolvers_;
0187 std::vector<edm::propagate_const<ESProductResolver*>> resolvers_;
0188 ActivityRegistry const* activityRegistry_;
0189 unsigned long long cacheIdentifier_;
0190 unsigned int iovIndex_;
0191 std::atomic<bool> isAvailable_;
0192 mutable std::atomic<bool> validityModificationUnderway_;
0193 };
0194 }
0195 }
0196 #endif