Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 13:28:14

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/DataProxyTemplate.h"
0029 #include "FWCore/Framework/interface/DataProxyProvider.h"
0030 
0031 // forward declarations
0032 namespace edm::eventsetup::test {
0033   class WorkingDummyProxy : public edm::eventsetup::DataProxyTemplate<DummyRecord, DummyData> {
0034   public:
0035     WorkingDummyProxy(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 DummyProxyProvider : public edm::eventsetup::DataProxyProvider {
0046   public:
0047     DummyProxyProvider(const DummyData& iData = DummyData()) : dummy_(iData) { usingRecord<DummyRecord>(); }
0048 
0049     void incrementData() { ++dummy_.value_; }
0050 
0051   protected:
0052     KeyedProxiesVector registerProxies(const EventSetupRecordKey&, unsigned int /* iovIndex */) override {
0053       KeyedProxiesVector keyedProxiesVector;
0054       edm::eventsetup::DataKey dataKey(edm::eventsetup::DataKey::makeTypeTag<DummyData>(), "");
0055       std::shared_ptr<WorkingDummyProxy> pProxy = std::make_shared<WorkingDummyProxy>(&dummy_);
0056       keyedProxiesVector.emplace_back(dataKey, pProxy);
0057       return keyedProxiesVector;
0058     }
0059 
0060   private:
0061     DummyData dummy_;
0062   };
0063 
0064 }  // namespace edm::eventsetup::test
0065 #endif