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 Maker;
20  class ExceptionToActionTable;
21 
22  class Maker {
23  public:
24  virtual ~Maker();
25  std::shared_ptr<maker::ModuleHolder> makeModule(MakeModuleParams const&,
26  signalslot::Signal<void(ModuleDescription const&)>& iPre,
27  signalslot::Signal<void(ModuleDescription const&)>& iPost) const;
28  std::unique_ptr<Worker> makeWorker(ExceptionToActionTable const*, maker::ModuleHolder const*) const;
29 
30  std::shared_ptr<maker::ModuleHolder> makeReplacementModule(edm::ParameterSet const& p) const {
31  return makeModule(p);
32  }
33 
34  protected:
36 
37  void throwConfigurationException(ModuleDescription const& md, cms::Exception& iException) const;
38 
39  void throwValidationException(MakeModuleParams const& p, cms::Exception& iException) const;
40 
41  void validateEDMType(std::string const& edmType, MakeModuleParams const& p) const;
42 
43  private:
44  virtual void fillDescriptions(ConfigurationDescriptions& iDesc) const = 0;
45  virtual std::shared_ptr<maker::ModuleHolder> makeModule(edm::ParameterSet const& p) const = 0;
46  virtual std::unique_ptr<Worker> makeWorker(ExceptionToActionTable const* actions,
47  ModuleDescription const& md,
48  maker::ModuleHolder const* mod) const = 0;
49  virtual const std::string& baseType() const = 0;
50  };
51 
52  template <class T>
53  class WorkerMaker : public Maker {
54  public:
55  //typedef T worker_type;
56  explicit WorkerMaker();
57 
58  private:
59  void fillDescriptions(ConfigurationDescriptions& iDesc) const override;
60  std::unique_ptr<Worker> makeWorker(ExceptionToActionTable const* actions,
61  ModuleDescription const& md,
62  maker::ModuleHolder const* mod) const override;
63  std::shared_ptr<maker::ModuleHolder> makeModule(edm::ParameterSet const& p) const override;
64  const std::string& baseType() const override;
65  };
66 
67  template <class T>
69 
70  template <class T>
72  T::fillDescriptions(iDesc);
73  T::prevalidate(iDesc);
74  }
75 
76  template <class T>
77  std::shared_ptr<maker::ModuleHolder> WorkerMaker<T>::makeModule(edm::ParameterSet const& p) const {
78  typedef T UserType;
79  typedef typename UserType::ModuleType ModuleType;
80  typedef MakeModuleHelper<ModuleType> MakerHelperType;
81 
82  return std::shared_ptr<maker::ModuleHolder>(
83  std::make_shared<maker::ModuleHolderT<ModuleType> >(MakerHelperType::template makeModule<UserType>(p), this));
84  }
85 
86  template <class T>
88  ModuleDescription const& md,
89  maker::ModuleHolder const* mod) const {
90  typedef T UserType;
91  typedef typename UserType::ModuleType ModuleType;
92  typedef edm::WorkerT<ModuleType> WorkerType;
93 
95  return std::make_unique<WorkerType>(h->module(), md, actions);
96  }
97 
98  template <class T>
100  return T::baseType();
101  }
102 
103 } // namespace edm
104 
105 #endif
FWCore Framework interface EventSetupRecordImplementation h
Helper function to determine trigger accepts.
roAction_t actions[nactions]
Definition: GenABIO.cc:181
void throwConfigurationException(ModuleDescription const &md, cms::Exception &iException) const
Definition: WorkerMaker.cc:38
std::unique_ptr< Worker > makeWorker(ExceptionToActionTable const *actions, ModuleDescription const &md, maker::ModuleHolder const *mod) const override
Definition: WorkerMaker.h:87
const std::string & baseType() const override
Definition: WorkerMaker.h:99
std::unique_ptr< Worker > makeWorker(ExceptionToActionTable const *, maker::ModuleHolder const *) const
Definition: WorkerMaker.cc:106
std::shared_ptr< T > module() const
Definition: ModuleHolder.h:60
std::shared_ptr< maker::ModuleHolder > makeModule(edm::ParameterSet const &p) const override
Definition: WorkerMaker.h:77
ModuleType
Definition: DQModule.h:24
def template(fileName, svg, replaceme="REPLACEME")
Definition: svgfig.py:521
void validateEDMType(std::string const &edmType, MakeModuleParams const &p) const
Definition: WorkerMaker.cc:45
virtual ~Maker()
Definition: WorkerMaker.cc:15
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
virtual void fillDescriptions(ConfigurationDescriptions &iDesc) const =0
virtual const std::string & baseType() const =0
std::shared_ptr< maker::ModuleHolder > makeModule(MakeModuleParams const &, signalslot::Signal< void(ModuleDescription const &)> &iPre, signalslot::Signal< void(ModuleDescription const &)> &iPost) const
Definition: WorkerMaker.cc:56
HLT enums.
ModuleDescription createModuleDescription(MakeModuleParams const &p) const
Definition: WorkerMaker.cc:17
std::shared_ptr< maker::ModuleHolder > makeReplacementModule(edm::ParameterSet const &p) const
Definition: WorkerMaker.h:30
void fillDescriptions(ConfigurationDescriptions &iDesc) const override
Definition: WorkerMaker.h:71
long double T
T mod(const T &a, const T &b)
Definition: ecalDccMap.h:4
void throwValidationException(MakeModuleParams const &p, cms::Exception &iException) const
Definition: WorkerMaker.cc:27