CMS 3D CMS Logo

ModuleHolder.h
Go to the documentation of this file.
1 #ifndef FWCore_Framework_ModuleHolder_h
2 #define FWCore_Framework_ModuleHolder_h
3 // -*- C++ -*-
4 //
5 // Package: FWCore/Framework
6 // Class : ModuleHolder
7 //
16 //
17 // Original Author: Chris Jones
18 // Created: Fri, 23 Aug 2013 17:47:04 GMT
19 //
20 
21 // system include files
22 #include <memory>
23 
24 // user include files
27 
28 // forward declarations
29 namespace edm {
30  class Maker;
31  class ModuleDescription;
32  class ProductRegistry;
33  class ExceptionToActionTable;
34  class PreallocationConfiguration;
35 
36  namespace maker {
37  class ModuleHolder {
38  public:
39  ModuleHolder(Maker const* iMaker):
40  m_maker(iMaker){}
41  virtual ~ModuleHolder() {}
42  std::unique_ptr<Worker> makeWorker(ExceptionToActionTable const* actions) const;
43 
44  virtual ModuleDescription const& moduleDescription() const = 0;
45  virtual void setModuleDescription(ModuleDescription const& iDesc) = 0;
46  virtual void preallocate(PreallocationConfiguration const& ) = 0;
48  virtual void replaceModuleFor(Worker*) const = 0;
49 
50  virtual std::unique_ptr<OutputModuleCommunicator> createOutputModuleCommunicator() = 0;
51  protected:
52  Maker const* m_maker;
53  };
54 
55  template<typename T>
56  class ModuleHolderT : public ModuleHolder {
57  public:
58  ModuleHolderT(std::shared_ptr<T> iModule, Maker const* iMaker) :ModuleHolder(iMaker), m_mod(iModule) {}
59  ~ModuleHolderT() override {}
60  std::shared_ptr<T> module() const { return m_mod; }
61  void replaceModuleFor(Worker* iWorker) const override {
62  auto w = dynamic_cast<WorkerT<T>*>(iWorker);
63  assert(nullptr!=w);
64  w->setModule(m_mod);
65  }
66  ModuleDescription const& moduleDescription() const override {
67  return m_mod->moduleDescription();
68  }
69  void setModuleDescription(ModuleDescription const& iDesc) override {
70  m_mod->setModuleDescription(iDesc);
71  }
72  void preallocate(PreallocationConfiguration const& iPrealloc) override {
73  m_mod->doPreallocate(iPrealloc);
74  }
75 
77  m_mod->registerProductsAndCallbacks(module().get(),iReg);
78  }
79 
80  std::unique_ptr<OutputModuleCommunicator>
83  }
84  private:
85  std::shared_ptr<T> m_mod;
86 
87  };
88  }
89 }
90 
91 #endif
ModuleHolderT(std::shared_ptr< T > iModule, Maker const *iMaker)
Definition: ModuleHolder.h:58
virtual ModuleDescription const & moduleDescription() const =0
void registerProductsAndCallbacks(ProductRegistry *iReg) override
Definition: ModuleHolder.h:76
roAction_t actions[nactions]
Definition: GenABIO.cc:187
const double w
Definition: UKUtility.cc:23
virtual void replaceModuleFor(Worker *) const =0
virtual void setModuleDescription(ModuleDescription const &iDesc)=0
void preallocate(PreallocationConfiguration const &iPrealloc) override
Definition: ModuleHolder.h:72
std::unique_ptr< Worker > makeWorker(ExceptionToActionTable const *actions) const
Definition: ModuleHolder.cc:23
ModuleDescription const & moduleDescription() const override
Definition: ModuleHolder.h:66
void replaceModuleFor(Worker *iWorker) const override
Definition: ModuleHolder.h:61
virtual void preallocate(PreallocationConfiguration const &)=0
void setModuleDescription(ModuleDescription const &iDesc) override
Definition: ModuleHolder.h:69
std::shared_ptr< T > module() const
Definition: ModuleHolder.h:60
virtual void registerProductsAndCallbacks(ProductRegistry *)=0
std::shared_ptr< T > m_mod
Definition: ModuleHolder.h:85
virtual std::unique_ptr< OutputModuleCommunicator > createOutputModuleCommunicator()=0
std::unique_ptr< OutputModuleCommunicator > createOutputModuleCommunicator() override
Definition: ModuleHolder.h:81
HLT enums.
ModuleHolder(Maker const *iMaker)
Definition: ModuleHolder.h:39
Definition: vlib.h:208
def move(src, dest)
Definition: eostools.py:511