CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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  virtual void fillDescriptions(ConfigurationDescriptions& iDesc) const;
63  virtual std::unique_ptr<Worker> makeWorker(ExceptionToActionTable const* actions, ModuleDescription const& md, maker::ModuleHolder const* mod) const;
64  virtual std::shared_ptr<maker::ModuleHolder> makeModule(edm::ParameterSet const& p) const;
65  virtual const std::string& baseType() const;
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 
86 
87  return std::shared_ptr<maker::ModuleHolder>(new maker::ModuleHolderT<ModuleType>{MakerHelperType::template makeModule<UserType>(p).release(),this});
88  }
89 
90  template <class T>
92  maker::ModuleHolder const* mod) const {
93  typedef T UserType;
94  typedef typename UserType::ModuleType ModuleType;
95  typedef edm::WorkerT<ModuleType> WorkerType;
96 
97  maker::ModuleHolderT<ModuleType> const* h = dynamic_cast<maker::ModuleHolderT<ModuleType> const*>(mod);
98  return std::unique_ptr<Worker>(new WorkerType(h->module(), md, actions));
99  }
100 
101 
102  template<class T>
104  return T::baseType();
105  }
106 
107 }
108 
109 #endif
void throwConfigurationException(ModuleDescription const &md, cms::Exception &iException) const
Definition: WorkerMaker.cc:43
virtual const std::string & baseType() const
Definition: WorkerMaker.h:103
virtual void fillDescriptions(ConfigurationDescriptions &iDesc) const
Definition: WorkerMaker.h:73
virtual const std::string & baseType() const =0
actions
Definition: Schedule.cc:362
virtual std::shared_ptr< maker::ModuleHolder > makeModule(edm::ParameterSet const &p) const
Definition: WorkerMaker.h:79
std::unique_ptr< Worker > makeWorker(ExceptionToActionTable const *, maker::ModuleHolder const *) const
Definition: WorkerMaker.cc:122
virtual void fillDescriptions(ConfigurationDescriptions &iDesc) const =0
void validateEDMType(std::string const &edmType, MakeModuleParams const &p) const
Definition: WorkerMaker.cc:52
virtual ~Maker()
Definition: WorkerMaker.cc:14
The Signals That Services Can Subscribe To This is based on ActivityRegistry h
Helper function to determine trigger accepts.
Definition: Activities.doc:4
string const
Definition: compareJSON.py:14
std::shared_ptr< maker::ModuleHolder > makeModule(MakeModuleParams const &, signalslot::Signal< void(ModuleDescription const &)> &iPre, signalslot::Signal< void(ModuleDescription const &)> &iPost) const
Definition: WorkerMaker.cc:64
ModuleDescription createModuleDescription(MakeModuleParams const &p) const
Definition: WorkerMaker.cc:18
std::shared_ptr< maker::ModuleHolder > makeReplacementModule(edm::ParameterSet const &p) const
Definition: WorkerMaker.h:32
long double T
T mod(const T &a, const T &b)
Definition: ecalDccMap.h:4
def template
Definition: svgfig.py:520
void throwValidationException(MakeModuleParams const &p, cms::Exception &iException) const
Definition: WorkerMaker.cc:29
virtual std::unique_ptr< Worker > makeWorker(ExceptionToActionTable const *actions, ModuleDescription const &md, maker::ModuleHolder const *mod) const
Definition: WorkerMaker.h:91