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
edm::Maker::throwConfigurationException
void throwConfigurationException(ModuleDescription const &md, cms::Exception &iException) const
Definition: WorkerMaker.cc:39
edm::Maker::fillDescriptions
virtual void fillDescriptions(ConfigurationDescriptions &iDesc) const =0
WorkerT.h
edm::Maker
Definition: WorkerMaker.h:22
edm
HLT enums.
Definition: AlignableModifier.h:19
AlCaHLTBitMon_ParallelJobs.p
p
Definition: AlCaHLTBitMon_ParallelJobs.py:153
mod
T mod(const T &a, const T &b)
Definition: ecalDccMap.h:4
edm::MakeModuleParams
Definition: MakeModuleParams.h:21
edm::maker::ModuleHolder
Definition: ModuleHolder.h:37
edm::WorkerT
Definition: Frameworkfwd.h:54
watchdog.const
const
Definition: watchdog.py:83
edm::ModuleDescription
Definition: ModuleDescription.h:21
edm::WorkerMaker::makeModule
std::shared_ptr< maker::ModuleHolder > makeModule(edm::ParameterSet const &p) const override
Definition: WorkerMaker.h:77
fillDescriptions
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
h
edm::maker::ModuleHolderT
Definition: EDAnalyzer.h:26
edm::Maker::createModuleDescription
ModuleDescription createModuleDescription(MakeModuleParams const &p) const
Definition: WorkerMaker.cc:18
edm::Maker::makeWorker
std::unique_ptr< Worker > makeWorker(ExceptionToActionTable const *, maker::ModuleHolder const *) const
Definition: WorkerMaker.cc:110
edm::MakeModuleHelper
Definition: MakeModuleHelper.h:30
edm::ConfigurationDescriptions
Definition: ConfigurationDescriptions.h:28
edm::Maker::makeModule
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
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
edm::Maker::makeReplacementModule
std::shared_ptr< maker::ModuleHolder > makeReplacementModule(edm::ParameterSet const &p) const
Definition: WorkerMaker.h:30
edm::ParameterSet
Definition: ParameterSet.h:36
edm::WorkerMaker::makeWorker
std::unique_ptr< Worker > makeWorker(ExceptionToActionTable const *actions, ModuleDescription const &md, maker::ModuleHolder const *mod) const override
Definition: WorkerMaker.h:87
ParameterSet
Definition: Functions.h:16
MakeModuleHelper.h
edm::WorkerMaker
Definition: WorkerMaker.h:53
Signal.h
MakeModuleParams.h
hcaldqm::ModuleType
ModuleType
Definition: DQModule.h:24
svgfig.template
def template(fileName, svg, replaceme="REPLACEME")
Definition: svgfig.py:521
edm::ExceptionToActionTable
Definition: ExceptionActions.h:16
ConfigurationDescriptions
edm::Maker::baseType
virtual const std::string & baseType() const =0
ModuleHolder.h
edm::Maker::validateEDMType
void validateEDMType(std::string const &edmType, MakeModuleParams const &p) const
Definition: WorkerMaker.cc:46
T
long double T
Definition: Basic3DVectorLD.h:48
edm::WorkerMaker::baseType
const std::string & baseType() const override
Definition: WorkerMaker.h:99
edm::Maker::throwValidationException
void throwValidationException(MakeModuleParams const &p, cms::Exception &iException) const
Definition: WorkerMaker.cc:28
edm::Maker::~Maker
virtual ~Maker()
Definition: WorkerMaker.cc:16
actions
roAction_t actions[nactions]
Definition: GenABIO.cc:181
cms::Exception
Definition: Exception.h:70
edm::WorkerMaker::WorkerMaker
WorkerMaker()
Definition: WorkerMaker.h:68
edm::WorkerMaker::fillDescriptions
void fillDescriptions(ConfigurationDescriptions &iDesc) const override
Definition: WorkerMaker.h:71
edm::signalslot::Signal
Definition: DelayedReader.h:26