File indexing completed on 2024-04-06 12:12:33
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020 #include "FWCore/Framework/interface/ESProducer.h"
0021 #include "FWCore/Framework/interface/ModuleFactory.h"
0022
0023 #include "Doodad.h"
0024 #include "GadgetRcd.h"
0025
0026
0027 #include <memory>
0028 #include <stdexcept>
0029
0030
0031
0032
0033 namespace edmtest {
0034
0035 class DoodadESProducer : public edm::ESProducer {
0036 public:
0037 DoodadESProducer(edm::ParameterSet const&);
0038 ~DoodadESProducer() override;
0039
0040 typedef std::unique_ptr<Doodad> ReturnType;
0041
0042 ReturnType produce(GadgetRcd const&);
0043
0044 private:
0045
0046 bool exceptionInformation_;
0047 };
0048
0049
0050
0051
0052
0053
0054
0055
0056
0057
0058
0059 DoodadESProducer::DoodadESProducer(edm::ParameterSet const& iConfig)
0060 : exceptionInformation_(iConfig.getUntrackedParameter<bool>("throwException", false)) {
0061
0062
0063 setWhatProduced(this);
0064
0065
0066 }
0067
0068 DoodadESProducer::~DoodadESProducer() {
0069
0070
0071 }
0072
0073
0074
0075
0076
0077
0078 DoodadESProducer::ReturnType DoodadESProducer::produce(GadgetRcd const& ) {
0079 if (exceptionInformation_) {
0080 throw std::runtime_error("test exception catching");
0081 }
0082
0083 using namespace edmtest;
0084
0085 auto pDoodad = std::make_unique<Doodad>();
0086
0087 pDoodad->a = 1;
0088
0089 return pDoodad;
0090 }
0091 }
0092
0093 using namespace edmtest;
0094
0095 DEFINE_FWK_EVENTSETUP_MODULE(DoodadESProducer);