Back to home page

Project CMSSW displayed by LXR

 
 

    


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

0001 /** \class edmtest::MissingDictionaryTestProducer
0002 \author W. David Dagenhart, created 26 May 2016
0003 */
0004 
0005 // Without manual intervention this simply tests the case where all
0006 // the test dictionaries are defined, which is not very interesting.
0007 // Its primary purpose is to be run manually where specific dictionaries
0008 // have been removed from classes_def.xml and checking that the proper
0009 // exceptions are thrown without having to generate this code from scratch.
0010 
0011 #include "FWCore/Framework/interface/one/EDProducer.h"
0012 #include "DataFormats/TestObjects/interface/MissingDictionaryTestObject.h"
0013 #include "FWCore/Framework/interface/Event.h"
0014 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0015 #include "FWCore/Utilities/interface/EDGetToken.h"
0016 #include "FWCore/Utilities/interface/InputTag.h"
0017 #include "FWCore/Framework/interface/MakerMacros.h"
0018 #include "DataFormats/Common/interface/View.h"
0019 
0020 #include <list>
0021 #include <vector>
0022 
0023 namespace edm {
0024   class EventSetup;
0025 }
0026 
0027 namespace edmtest {
0028 
0029   class MissingDictionaryTestProducer : public edm::one::EDProducer<> {
0030   public:
0031     explicit MissingDictionaryTestProducer(edm::ParameterSet const&);
0032     ~MissingDictionaryTestProducer() override;
0033 
0034     void produce(edm::Event&, edm::EventSetup const&) override;
0035 
0036   private:
0037     edm::EDGetTokenT<MissingDictionaryTestA> inputToken1_;
0038     edm::EDGetTokenT<std::vector<MissingDictionaryTestA> > inputToken2_;
0039     edm::EDGetTokenT<std::list<MissingDictionaryTestA> > inputToken3_;
0040   };
0041 
0042   MissingDictionaryTestProducer::MissingDictionaryTestProducer(edm::ParameterSet const& pset) {
0043     consumes<edm::View<MissingDictionaryTestA> >(pset.getParameter<edm::InputTag>("inputTag"));
0044     inputToken1_ = consumes<MissingDictionaryTestA>(pset.getParameter<edm::InputTag>("inputTag"));
0045     inputToken2_ = consumes<std::vector<MissingDictionaryTestA> >(pset.getParameter<edm::InputTag>("inputTag"));
0046     inputToken3_ = consumes<std::list<MissingDictionaryTestA> >(pset.getParameter<edm::InputTag>("inputTag"));
0047 
0048     produces<MissingDictionaryTestA>();
0049     produces<MissingDictionaryTestA>("anInstance");
0050     produces<std::vector<MissingDictionaryTestA> >();
0051     produces<std::vector<MissingDictionaryTestA> >("anInstance");
0052     produces<std::list<MissingDictionaryTestA> >();
0053   }
0054 
0055   MissingDictionaryTestProducer::~MissingDictionaryTestProducer() {}
0056 
0057   void MissingDictionaryTestProducer::produce(edm::Event& event, edm::EventSetup const&) {
0058     edm::Handle<MissingDictionaryTestA> h1;
0059     //event.getByToken(inputToken1_, h1);
0060 
0061     edm::Handle<std::vector<MissingDictionaryTestA> > h2;
0062     //event.getByToken(inputToken2_, h2);
0063 
0064     auto result1 = std::make_unique<MissingDictionaryTestA>();
0065     event.put(std::move(result1));
0066 
0067     auto result2 = std::make_unique<MissingDictionaryTestA>();
0068     event.put(std::move(result2), "anInstance");
0069 
0070     auto result3 = std::make_unique<std::vector<MissingDictionaryTestA> >();
0071     event.put(std::move(result3));
0072 
0073     auto result4 = std::make_unique<std::vector<MissingDictionaryTestA> >();
0074     event.put(std::move(result4), "anInstance");
0075   }
0076 }  // namespace edmtest
0077 using edmtest::MissingDictionaryTestProducer;
0078 DEFINE_FWK_MODULE(MissingDictionaryTestProducer);