IntProducer_module.cc
Go to the documentation of this file.
1 //--------------------------------------------------------------------
2 // Produces an IntProduct instance.
3 //--------------------------------------------------------------------
4 
13 
14 #include "fhiclcpp/types/Atom.h"
15 
17 
18 #include <iostream>
19 #include <memory>
20 
21 using namespace fhicl;
22 namespace {
23 
24 } // namespace
25 
26 namespace arttest {
27  class IntProducer;
28 }
29 
31 
33 public:
34  struct Config {
35  Atom<int> ivalue{Name("ivalue")};
36  Atom<unsigned long> branchType{Name("branchType"), art::InEvent};
37  };
39  explicit IntProducer(Parameters const& p, art::ProcessingFrame const&);
40 
41 private:
42  void produce(art::Event& e, art::ProcessingFrame const&) override;
43  void endSubRun(art::SubRun& sr, art::ProcessingFrame const&) override;
44  void endRun(art::Run& r, art::ProcessingFrame const&) override;
45 
46  int const value_;
48 }; // IntProducer
49 
50 IntProducer::IntProducer(Parameters const& p, art::ProcessingFrame const&)
51  : art::SharedProducer{p}
52  , value_{p().ivalue()} // enums don't usually have a conversion from string
53  , branchType_{art::BranchType(p().branchType())}
54 {
55  art::test::run_time_produces<IntProduct>(this, branchType_);
56  async<art::InEvent>();
57 }
58 
59 void
61 {
63  e.put(std::make_unique<IntProduct>(value_));
64 }
65 
66 void
68 {
70  sr.put(std::make_unique<IntProduct>(value_), art::subRunFragment());
71 }
72 
73 void
75 {
76  if (branchType_ == art::InRun)
77  r.put(std::make_unique<IntProduct>(value_), art::runFragment());
78 }
79 
art::BranchType const branchType_
Definition: Run.h:21
constexpr auto runFragment()
void produce(art::Event &e, art::ProcessingFrame const &) override
const double e
#define DEFINE_ART_MODULE(klass)
Definition: ModuleMacros.h:68
parameter set interface
p
Definition: test.py:228
constexpr auto subRunFragment()
void endSubRun(art::SubRun &sr, art::ProcessingFrame const &) override
BranchType
Definition: BranchType.h:18
void endRun(art::Run &r, art::ProcessingFrame const &) override
ProductID put(std::unique_ptr< PROD > &&edp, FullSemantic< Level::Run > const semantic)
Definition: DataViewImpl.h:692
static const double sr
Definition: Units.h:167
AdcRoiViewer::Name Name