Back to home page

Project CMSSW displayed by LXR

 
 

    


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

0001 // -*- C++ -*-
0002 //
0003 // Package:    DummyLooper
0004 // Class:      DummyLooper
0005 //
0006 /**\class DummyLooper DummyLooper.h FWCore/DummyLooper/interface/DummyLooper.h
0007 
0008  Description: <one line class summary>
0009 
0010  Implementation:
0011      <Notes on implementation>
0012 */
0013 //
0014 // Original Author:  Valentin Kuznetsov
0015 //         Created:  Tue Jul 18 10:17:05 EDT 2006
0016 //
0017 //
0018 
0019 // system include files
0020 #include <memory>
0021 
0022 // user include files
0023 #include "FWCore/Framework/interface/LooperFactory.h"
0024 #include "FWCore/Framework/interface/ESProducerLooper.h"
0025 
0026 #include "FWCore/Framework/test/DummyData.h"
0027 #include "FWCore/Framework/test/DummyRecord.h"
0028 #include "FWCore/Utilities/interface/get_underlying_safe.h"
0029 
0030 //
0031 // class decleration
0032 //
0033 using namespace edm::eventsetup::test;
0034 
0035 class DummyLooper : public edm::ESProducerLooper {
0036 public:
0037   DummyLooper(const edm::ParameterSet&);
0038   ~DummyLooper();
0039 
0040   typedef std::shared_ptr<DummyData> ReturnType;
0041   typedef std::shared_ptr<DummyData const> ConstReturnType;
0042 
0043   ReturnType produce(const DummyRecord&);
0044 
0045   void startingNewLoop(unsigned int) {}
0046   Status duringLoop(const edm::Event&, const edm::EventSetup&) { return issueStop_ ? kStop : kContinue; }
0047   Status endOfLoop(const edm::EventSetup&, unsigned int) {
0048     (data_->value_)++;
0049     ++counter_;
0050     return counter_ == 2 ? kStop : kContinue;
0051   }
0052 
0053 private:
0054   // ----------member data ---------------------------
0055   ConstReturnType data() const { return get_underlying_safe(data_); }
0056   ReturnType& data() { return get_underlying_safe(data_); }
0057 
0058   edm::propagate_const<ReturnType> data_;
0059   int counter_;
0060   bool issueStop_;
0061 };
0062 
0063 //
0064 // constants, enums and typedefs
0065 //
0066 
0067 //
0068 // static data member definitions
0069 //
0070 
0071 //
0072 // constructors and destructor
0073 //
0074 DummyLooper::DummyLooper(const edm::ParameterSet& iConfig)
0075     : data_(new DummyData(iConfig.getUntrackedParameter<int>("value"))),
0076       counter_(0),
0077       issueStop_(iConfig.getUntrackedParameter<bool>("issueStop", false)) {
0078   //the following line is needed to tell the framework what
0079   // data is being produced
0080   setWhatProduced(this);
0081 
0082   //now do what ever other initialization is needed
0083 }
0084 
0085 DummyLooper::~DummyLooper() {
0086   // do anything here that needs to be done at desctruction time
0087   // (e.g. close files, deallocate resources etc.)
0088 }
0089 
0090 //
0091 // member functions
0092 //
0093 
0094 // ------------ method called to produce the data  ------------
0095 DummyLooper::ReturnType DummyLooper::produce(const DummyRecord&) { return data(); }
0096 
0097 //define this as a plug-in
0098 DEFINE_FWK_LOOPER(DummyLooper);