File indexing completed on 2024-04-06 12:12:16
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020 #include <memory>
0021
0022
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
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
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
0065
0066
0067
0068
0069
0070
0071
0072
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
0079
0080 setWhatProduced(this);
0081
0082
0083 }
0084
0085 DummyLooper::~DummyLooper() {
0086
0087
0088 }
0089
0090
0091
0092
0093
0094
0095 DummyLooper::ReturnType DummyLooper::produce(const DummyRecord&) { return data(); }
0096
0097
0098 DEFINE_FWK_LOOPER(DummyLooper);