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>
9 #include "sigc++/signal.h"
10 
11 
12 namespace edm {
14  class ModuleDescription;
15  class ParameterSet;
16 
17  class Maker {
18  public:
19  virtual ~Maker();
20  std::auto_ptr<Worker> makeWorker(WorkerParams const&,
21  sigc::signal<void, ModuleDescription const&>& iPre,
22  sigc::signal<void, ModuleDescription const&>& iPost) const;
23  void swapModule(Worker*, ParameterSet const&);
24  protected:
26 
28  sigc::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::auto_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::auto_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::auto_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::auto_ptr<ModuleType> module(WorkerType::template makeModule<UserType>(md, *p.pset_));
73  return std::auto_ptr<Worker>(new WorkerType(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::auto_ptr<ModuleType> module(WorkerType::template makeModule<UserType>(w->description(), p));
87 
88  wt->setModule(module);
89  }
90 
91  template<class T>
92  const std::string& WorkerMaker<T>::baseType() const {
93  return T::baseType();
94  }
95 
96 }
97 
98 #endif
ModuleDescription const & description() const
Definition: Worker.h:73
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
std::auto_ptr< Worker > makeWorker(WorkerParams const &, sigc::signal< void, ModuleDescription const & > &iPre, sigc::signal< void, ModuleDescription const & > &iPost) const
Definition: WorkerMaker.cc:66
void throwConfigurationException(ModuleDescription const &md, sigc::signal< void, ModuleDescription const & > &post, cms::Exception &iException) const
Definition: WorkerMaker.cc:43
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 void implSwapModule(Worker *, ParameterSet const &)
Definition: WorkerMaker.h:78
virtual ~Maker()
Definition: WorkerMaker.cc:15
long double T
def template
Definition: svgfig.py:520
virtual std::auto_ptr< Worker > makeWorker(WorkerParams const &p, ModuleDescription const &md) const
Definition: WorkerMaker.h:67
T w() const
void throwValidationException(WorkerParams const &p, cms::Exception &iException) const
Definition: WorkerMaker.cc:29