File indexing completed on 2024-04-06 12:12:23
0001 #ifndef Framework_DummyProvider_h
0002 #define Framework_DummyProvider_h
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022 #include <memory>
0023
0024
0025 #include "FWCore/Framework/test/DummyRecord.h"
0026 #include "FWCore/Framework/test/DummyData.h"
0027
0028 #include "FWCore/Framework/interface/ESProductResolverTemplate.h"
0029 #include "FWCore/Framework/interface/ESProductResolverProvider.h"
0030
0031
0032 namespace edm::eventsetup::test {
0033 class WorkingDummyResolver : public edm::eventsetup::ESProductResolverTemplate<DummyRecord, DummyData> {
0034 public:
0035 WorkingDummyResolver(const DummyData* iDummy) : data_(iDummy) {}
0036
0037 protected:
0038 const value_type* make(const record_type&, const DataKey&) final { return data_; }
0039 void const* getAfterPrefetchImpl() const final { return data_; }
0040
0041 private:
0042 const DummyData* data_;
0043 };
0044
0045 class DummyESProductResolverProvider : public edm::eventsetup::ESProductResolverProvider {
0046 public:
0047 DummyESProductResolverProvider(const DummyData& iData = DummyData()) : dummy_(iData) { usingRecord<DummyRecord>(); }
0048
0049 void incrementData() { ++dummy_.value_; }
0050
0051 protected:
0052 KeyedResolversVector registerResolvers(const EventSetupRecordKey&, unsigned int ) override {
0053 KeyedResolversVector keyedResolversVector;
0054 edm::eventsetup::DataKey dataKey(edm::eventsetup::DataKey::makeTypeTag<DummyData>(), "");
0055 std::shared_ptr<WorkingDummyResolver> pResolver = std::make_shared<WorkingDummyResolver>(&dummy_);
0056 keyedResolversVector.emplace_back(dataKey, pResolver);
0057 return keyedResolversVector;
0058 }
0059
0060 private:
0061 DummyData dummy_;
0062 };
0063
0064 }
0065 #endif