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