IntReaderThenProducer_module.cc
Go to the documentation of this file.
7 #include "fhiclcpp/types/Atom.h"
8 
9 #include <memory>
10 
11 namespace art {
12  namespace test {
13  class IntReaderThenProducer;
14  }
15 }
16 
17 using namespace fhicl;
18 
20 public:
21  struct Config {
22  Atom<std::string> inputTag{Name{"inputTag"}};
23  Atom<int> deltaValue{Name{"deltaValue"}};
24  Atom<bool> shouldSucceed{
25  Name{"shouldSucceed"},
26  Comment{
27  "The 'shouldSucceed' parameter indicates if the product retrieval,\n"
28  "corresponding to the above 'inputTag' value, should be successful."},
29  true};
30  };
32  explicit IntReaderThenProducer(Parameters const& p, ProcessingFrame const&);
33 
34  // Plugins should not be copied or assigned.
37  IntReaderThenProducer& operator=(IntReaderThenProducer const&) = delete;
38  IntReaderThenProducer& operator=(IntReaderThenProducer&&) = delete;
39 
40 private:
41  void produce(Event& e, ProcessingFrame const&) override;
42 
44  int const deltaValue_;
45  bool const shouldSucceed_;
46 };
47 
49  ProcessingFrame const&)
50  : SharedProducer{p}
51  , token_{consumes<arttest::IntProduct>(p().inputTag())}
52  , deltaValue_{p().deltaValue()}
53  , shouldSucceed_{p().shouldSucceed()}
54 {
55  produces<arttest::IntProduct>();
56  async<InEvent>();
57 }
58 
59 void
61 {
62  // getByToken adds parent for the about-to-be-created IntProduct.
64  bool const fetched{e.getByToken(token_, intH)};
65  assert(shouldSucceed_ == fetched);
66  auto new_value = std::make_unique<arttest::IntProduct>(deltaValue_);
67  if (shouldSucceed_) {
68  new_value->value += intH->value;
69  }
70  e.put(move(new_value));
71 }
72 
bool getByToken(ProductToken< PROD > const &, Handle< PROD > &result) const
Definition: DataViewImpl.h:451
Definition: test.py:1
ProductToken< arttest::IntProduct > const token_
IntReaderThenProducer(Parameters const &p, ProcessingFrame const &)
const double e
#define DEFINE_ART_MODULE(klass)
Definition: ModuleMacros.h:68
parameter set interface
p
Definition: test.py:228
ProductID put(std::unique_ptr< PROD > &&edp, FullSemantic< Level::Run > const semantic)
Definition: DataViewImpl.h:692
void produce(Event &e, ProcessingFrame const &) override