LArSoft  v09_90_00
Liquid Argon Software toolkit - https://larsoft.org/
ModuleBase.h
Go to the documentation of this file.
1 #ifndef art_Framework_Core_ModuleBase_h
2 #define art_Framework_Core_ModuleBase_h
3 // vim: set sw=2 expandtab :
4 
12 
13 #include <array>
14 #include <memory>
15 #include <optional>
16 #include <string>
17 #include <vector>
18 
19 namespace art {
20  class ModuleBase {
21  public:
22  virtual ~ModuleBase() noexcept;
23  ModuleBase();
24 
25  ModuleDescription const& moduleDescription() const;
27 
28  std::array<std::vector<ProductInfo>, NumBranchTypes> const& getConsumables()
29  const;
30  void sortConsumables(std::string const& current_process_name);
31 
32  std::unique_ptr<Worker> makeWorker(WorkerParams const& wp);
33 
34  protected:
35  // Consumes information
37 
38  template <typename T, BranchType = InEvent>
40  template <typename Element, BranchType = InEvent>
42  template <typename T, BranchType = InEvent>
43  void consumesMany();
44 
45  template <typename T, BranchType = InEvent>
47  template <typename Element, BranchType = InEvent>
49  template <typename T, BranchType = InEvent>
50  void mayConsumeMany();
51 
52  private:
53  virtual std::unique_ptr<Worker> doMakeWorker(WorkerParams const& wp) = 0;
54 
55  std::optional<ModuleDescription> md_{std::nullopt};
57  };
58 
59  template <typename T, BranchType BT>
62  {
63  return collector_.consumes<T, BT>(tag);
64  }
65 
66  template <typename T, BranchType BT>
69  {
70  return collector_.consumesView<T, BT>(tag);
71  }
72 
73  template <typename T, BranchType BT>
74  void
76  {
77  collector_.consumesMany<T, BT>();
78  }
79 
80  template <typename T, BranchType BT>
83  {
84  return collector_.mayConsume<T, BT>(tag);
85  }
86 
87  template <typename T, BranchType BT>
90  {
91  return collector_.mayConsumeView<T, BT>(tag);
92  }
93 
94  template <typename T, BranchType BT>
95  void
97  {
98  collector_.mayConsumeMany<T, BT>();
99  }
100 
101 } // namespace art
102 
103 #endif /* art_Framework_Core_ModuleBase_h */
104 
105 // Local Variables:
106 // mode: c++
107 // End:
ProductToken< T > mayConsume(InputTag const &)
ConsumesCollector collector_
Definition: ModuleBase.h:56
ConsumesCollector & consumesCollector()
Definition: ModuleBase.cc:57
void mayConsumeMany()
Definition: ModuleBase.h:96
ViewToken< Element > consumesView(InputTag const &)
ProductToken< T > mayConsume(InputTag const &)
Definition: ModuleBase.h:82
ViewToken< Element > consumesView(InputTag const &)
void sortConsumables(std::string const &current_process_name)
Definition: ModuleBase.cc:49
ProductToken< T > consumes(InputTag const &)
ViewToken< Element > mayConsumeView(InputTag const &)
void setModuleDescription(ModuleDescription const &)
Definition: ModuleBase.cc:31
virtual ~ModuleBase() noexcept
virtual std::unique_ptr< Worker > doMakeWorker(WorkerParams const &wp)=0
std::array< std::vector< ProductInfo >, NumBranchTypes > const & getConsumables() const
Definition: ModuleBase.cc:43
std::unique_ptr< Worker > makeWorker(WorkerParams const &wp)
Definition: ModuleBase.cc:37
std::optional< ModuleDescription > md_
Definition: ModuleBase.h:55
void consumesMany()
Definition: ModuleBase.h:75
ProductToken< T > consumes(InputTag const &)
Definition: ModuleBase.h:61
Definition: MVAAlg.h:12
ViewToken< Element > mayConsumeView(InputTag const &)
ModuleDescription const & moduleDescription() const
Definition: ModuleBase.cc:13