Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:12:23

0001 #ifndef Framework_DummyProvider_h
0002 #define Framework_DummyProvider_h
0003 // -*- C++ -*-
0004 //
0005 // Package:     Framework
0006 // Class  :     DummyProvider
0007 //
0008 /**\class DummyProvider DummyProvider.h FWCore/Framework/interface/DummyProvider.h
0009 
0010  Description: <one line class summary>
0011 
0012  Usage:
0013     <usage>
0014 
0015 */
0016 //
0017 // Author:      Chris Jones
0018 // Created:     Thu May 26 13:37:48 EDT 2005
0019 //
0020 
0021 // system include files
0022 #include <memory>
0023 
0024 // user include files
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 // forward declarations
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 /* iovIndex */) 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 }  // namespace edm::eventsetup::test
0065 #endif