CMS 3D CMS Logo

WorkerMaker.h
Go to the documentation of this file.
1 #ifndef FWCore_Framework_WorkerMaker_h
2 #define FWCore_Framework_WorkerMaker_h
3 
4 #include <cassert>
5 #include <memory>
6 #include <string>
7 
12 
14 
15 namespace edm {
17  class ModuleDescription;
18  class ParameterSet;
19  class ExceptionToActionTable;
20 
21  class Maker {
22  public:
23  virtual ~Maker();
24  std::shared_ptr<maker::ModuleHolder> makeModule(MakeModuleParams const&,
25  signalslot::Signal<void(ModuleDescription const&)>& iPre,
26  signalslot::Signal<void(ModuleDescription const&)>& iPost) const;
27  std::unique_ptr<Worker> makeWorker(ExceptionToActionTable const*, maker::ModuleHolder const*) const;
28 
29  std::shared_ptr<maker::ModuleHolder> makeReplacementModule(edm::ParameterSet const& p) const {
30  return makeModule(p);
31  }
32 
33  protected:
35 
36  void throwConfigurationException(ModuleDescription const& md, cms::Exception& iException) const;
37 
38  void throwValidationException(MakeModuleParams const& p, cms::Exception& iException) const;
39 
40  void validateEDMType(std::string const& edmType, MakeModuleParams const& p) const;
41 
42  private:
43  virtual void fillDescriptions(ConfigurationDescriptions& iDesc) const = 0;
44  virtual std::shared_ptr<maker::ModuleHolder> makeModule(edm::ParameterSet const& p) const = 0;
45  virtual std::unique_ptr<Worker> makeWorker(ExceptionToActionTable const* actions,
46  ModuleDescription const& md,
47  maker::ModuleHolder const* mod) const = 0;
48  virtual const std::string& baseType() const = 0;
49  };
50 
51  template <class T>
52  class WorkerMaker : public Maker {
53  public:
54  //typedef T worker_type;
55  explicit WorkerMaker();
56 
57  private:
58  void fillDescriptions(ConfigurationDescriptions& iDesc) const override;
59  std::unique_ptr<Worker> makeWorker(ExceptionToActionTable const* actions,
60  ModuleDescription const& md,
61  maker::ModuleHolder const* mod) const override;
62  std::shared_ptr<maker::ModuleHolder> makeModule(edm::ParameterSet const& p) const override;
63  const std::string& baseType() const override;
64  };
65 
66  template <class T>
68 
69  template <class T>
71  T::fillDescriptions(iDesc);
72  T::prevalidate(iDesc);
73  }
74 
75  template <class T>
76  std::shared_ptr<maker::ModuleHolder> WorkerMaker<T>::makeModule(edm::ParameterSet const& p) const {
77  typedef T UserType;
78  typedef typename UserType::ModuleType ModuleType;
79  typedef MakeModuleHelper<ModuleType> MakerHelperType;
80 
81  return std::shared_ptr<maker::ModuleHolder>(
82  std::make_shared<maker::ModuleHolderT<ModuleType> >(MakerHelperType::template makeModule<UserType>(p), this));
83  }
84 
85  template <class T>
87  ModuleDescription const& md,
88  maker::ModuleHolder const* mod) const {
89  typedef T UserType;
90  typedef typename UserType::ModuleType ModuleType;
91  typedef edm::WorkerT<ModuleType> WorkerType;
92 
94  return std::make_unique<WorkerType>(h->module(), md, actions);
95  }
96 
97  template <class T>
99  return T::baseType();
100  }
101 
102 } // namespace edm
103 
104 #endif
void throwValidationException(MakeModuleParams const &p, cms::Exception &iException) const
Definition: WorkerMaker.cc:28
const std::string & baseType() const override
Definition: WorkerMaker.h:98
roAction_t actions[nactions]
Definition: GenABIO.cc:181
ModuleDescription createModuleDescription(MakeModuleParams const &p) const
Definition: WorkerMaker.cc:18
std::unique_ptr< Worker > makeWorker(ExceptionToActionTable const *actions, ModuleDescription const &md, maker::ModuleHolder const *mod) const override
Definition: WorkerMaker.h:86
std::shared_ptr< maker::ModuleHolder > makeModule(edm::ParameterSet const &p) const override
Definition: WorkerMaker.h:76
void fillDescriptions(ConfigurationDescriptions &iDesc) const override
Definition: WorkerMaker.h:70
void throwConfigurationException(ModuleDescription const &md, cms::Exception &iException) const
Definition: WorkerMaker.cc:39
virtual const std::string & baseType() const =0
void validateEDMType(std::string const &edmType, MakeModuleParams const &p) const
Definition: WorkerMaker.cc:46
virtual void fillDescriptions(ConfigurationDescriptions &iDesc) const =0
ModuleType
Definition: DQModule.h:24
def template(fileName, svg, replaceme="REPLACEME")
Definition: svgfig.py:521
std::shared_ptr< maker::ModuleHolder > makeModule(MakeModuleParams const &, signalslot::Signal< void(ModuleDescription const &)> &iPre, signalslot::Signal< void(ModuleDescription const &)> &iPost) const
Definition: WorkerMaker.cc:57
virtual ~Maker()
Definition: WorkerMaker.cc:16
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
std::shared_ptr< maker::ModuleHolder > makeReplacementModule(edm::ParameterSet const &p) const
Definition: WorkerMaker.h:29
HLT enums.
std::unique_ptr< Worker > makeWorker(ExceptionToActionTable const *, maker::ModuleHolder const *) const
Definition: WorkerMaker.cc:110
The Signals That Services Can Subscribe To This is based on ActivityRegistry h
Helper function to determine trigger accepts.
Definition: Activities.doc:4
long double T
T mod(const T &a, const T &b)
Definition: ecalDccMap.h:4