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 
6 
7 #include <memory>
8 #include <string>
10 
11 
12 namespace edm {
14  class ModuleDescription;
15  class ParameterSet;
16 
17  class Maker {
18  public:
19  virtual ~Maker();
20  std::unique_ptr<Worker> makeWorker(WorkerParams const&,
21  signalslot::Signal<void(ModuleDescription const&)>& iPre,
22  signalslot::Signal<void(ModuleDescription const&)>& iPost) const;
23  void swapModule(Worker*, ParameterSet const&);
24  protected:
26 
28  signalslot::Signal<void(ModuleDescription const&)>& post,
29  cms::Exception & iException) const;
30 
32  cms::Exception & iException) const;
33 
34  void validateEDMType(std::string const& edmType, WorkerParams const& p) const;
35 
36  private:
37  virtual void fillDescriptions(ConfigurationDescriptions& iDesc) const = 0;
38  virtual std::unique_ptr<Worker> makeWorker(WorkerParams const& p,
39  ModuleDescription const& md) const = 0;
40  virtual const std::string& baseType() const =0;
41  virtual void implSwapModule(Worker*, ParameterSet const&)=0;
42  };
43 
44  template <class T>
45  class WorkerMaker : public Maker {
46  public:
47  //typedef T worker_type;
48  explicit WorkerMaker();
49  private:
50  virtual void fillDescriptions(ConfigurationDescriptions& iDesc) const;
51  virtual std::unique_ptr<Worker> makeWorker(WorkerParams const& p, ModuleDescription const& md) const;
52  virtual const std::string& baseType() const;
53  virtual void implSwapModule(Worker*, ParameterSet const&);
54  };
55 
56  template <class T>
58  }
59 
60  template <class T>
62  T::fillDescriptions(iDesc);
63  T::prevalidate(iDesc);
64  }
65 
66  template <class T>
67  std::unique_ptr<Worker> WorkerMaker<T>::makeWorker(WorkerParams const& p, ModuleDescription const& md) const {
68  typedef T UserType;
69  typedef typename UserType::ModuleType ModuleType;
70  typedef typename UserType::WorkerType WorkerType;
71 
72  std::unique_ptr<ModuleType> module(WorkerType::template makeModule<UserType>(md, *p.pset_));
73  return std::unique_ptr<Worker>(new WorkerType(std::move(module), md, p));
74  }
75 
76 
77  template <class T>
79  typedef T UserType;
80  typedef typename UserType::ModuleType ModuleType;
81  typedef typename UserType::WorkerType WorkerType;
82 
83  WorkerType* wt = dynamic_cast<WorkerType*>(w);
84  assert(0!=wt);
85 
86  std::unique_ptr<ModuleType> module(WorkerType::template makeModule<UserType>(w->description(), p));
87 
88  wt->setModule(std::move(module));
89  }
90 
91  template<class T>
93  return T::baseType();
94  }
95 
96 }
97 
98 #endif
ModuleDescription const & description() const
Definition: Worker.h:77
ParameterSet * pset_
Definition: WorkerParams.h:38
virtual const std::string & baseType() const
Definition: WorkerMaker.h:92
virtual void fillDescriptions(ConfigurationDescriptions &iDesc) const
Definition: WorkerMaker.h:61
virtual const std::string & baseType() const =0
void swapModule(Worker *, ParameterSet const &)
Definition: WorkerMaker.cc:111
void validateEDMType(std::string const &edmType, WorkerParams const &p) const
Definition: WorkerMaker.cc:54
virtual void implSwapModule(Worker *, ParameterSet const &)=0
ModuleDescription createModuleDescription(WorkerParams const &p) const
Definition: WorkerMaker.cc:19
virtual void fillDescriptions(ConfigurationDescriptions &iDesc) const =0
virtual std::unique_ptr< Worker > makeWorker(WorkerParams const &p, ModuleDescription const &md) const
Definition: WorkerMaker.h:67
virtual void implSwapModule(Worker *, ParameterSet const &)
Definition: WorkerMaker.h:78
virtual ~Maker()
Definition: WorkerMaker.cc:15
void throwConfigurationException(ModuleDescription const &md, signalslot::Signal< void(ModuleDescription const &)> &post, cms::Exception &iException) const
Definition: WorkerMaker.cc:43
std::unique_ptr< Worker > makeWorker(WorkerParams const &, signalslot::Signal< void(ModuleDescription const &)> &iPre, signalslot::Signal< void(ModuleDescription const &)> &iPost) const
Definition: WorkerMaker.cc:66
T w() const
long double T
def template
Definition: svgfig.py:520
void throwValidationException(WorkerParams const &p, cms::Exception &iException) const
Definition: WorkerMaker.cc:29