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) : m_maker(iMaker) {}
40  virtual ~ModuleHolder() {}
41  std::unique_ptr<Worker> makeWorker(ExceptionToActionTable const* actions) const;
42 
43  virtual ModuleDescription const& moduleDescription() const = 0;
44  virtual void setModuleDescription(ModuleDescription const& iDesc) = 0;
45  virtual void preallocate(PreallocationConfiguration const&) = 0;
47  virtual void replaceModuleFor(Worker*) const = 0;
48 
49  virtual std::unique_ptr<OutputModuleCommunicator> createOutputModuleCommunicator() = 0;
50 
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 { return m_mod->moduleDescription(); }
67  void setModuleDescription(ModuleDescription const& iDesc) override { m_mod->setModuleDescription(iDesc); }
68  void preallocate(PreallocationConfiguration const& iPrealloc) override { m_mod->doPreallocate(iPrealloc); }
69 
71  m_mod->registerProductsAndCallbacks(module().get(), iReg);
72  }
73 
74  std::unique_ptr<OutputModuleCommunicator> createOutputModuleCommunicator() override {
76  }
77 
78  private:
79  std::shared_ptr<T> m_mod;
80  };
81  } // namespace maker
82 } // namespace edm
83 
84 #endif
edm::maker::ModuleHolderT::replaceModuleFor
void replaceModuleFor(Worker *iWorker) const override
Definition: ModuleHolder.h:61
edm::maker::ModuleHolder::preallocate
virtual void preallocate(PreallocationConfiguration const &)=0
edm::maker::ModuleHolderT::ModuleHolderT
ModuleHolderT(std::shared_ptr< T > iModule, Maker const *iMaker)
Definition: ModuleHolder.h:58
WorkerT.h
edm::Maker
Definition: WorkerMaker.h:22
edm::maker::ModuleHolder::moduleDescription
virtual ModuleDescription const & moduleDescription() const =0
edm
HLT enums.
Definition: AlignableModifier.h:19
edm::maker::ModuleHolder::~ModuleHolder
virtual ~ModuleHolder()
Definition: ModuleHolder.h:40
edm::maker::ModuleHolderT::module
std::shared_ptr< T > module() const
Definition: ModuleHolder.h:60
cms::cuda::assert
assert(be >=bs)
edm::maker::ModuleHolder
Definition: ModuleHolder.h:37
edm::maker::ModuleHolder::ModuleHolder
ModuleHolder(Maker const *iMaker)
Definition: ModuleHolder.h:39
edm::WorkerT
Definition: Frameworkfwd.h:54
edm::ModuleDescription
Definition: ModuleDescription.h:21
edm::ProductRegistry
Definition: ProductRegistry.h:34
edm::maker::ModuleHolderT::preallocate
void preallocate(PreallocationConfiguration const &iPrealloc) override
Definition: ModuleHolder.h:68
edm::maker::ModuleHolder::createOutputModuleCommunicator
virtual std::unique_ptr< OutputModuleCommunicator > createOutputModuleCommunicator()=0
w
const double w
Definition: UKUtility.cc:23
edm::maker::ModuleHolder::m_maker
Maker const * m_maker
Definition: ModuleHolder.h:52
edm::maker::ModuleHolderT::setModuleDescription
void setModuleDescription(ModuleDescription const &iDesc) override
Definition: ModuleHolder.h:67
edm::maker::ModuleHolderT::m_mod
std::shared_ptr< T > m_mod
Definition: ModuleHolder.h:79
edm::maker::ModuleHolderT
Definition: EDAnalyzer.h:26
edm::maker::ModuleHolderT::~ModuleHolderT
~ModuleHolderT() override
Definition: ModuleHolder.h:59
edm::Worker
Definition: Worker.h:83
edm::maker::ModuleHolder::setModuleDescription
virtual void setModuleDescription(ModuleDescription const &iDesc)=0
edm::get
T const & get(Event const &event, InputTag const &tag) noexcept(false)
Definition: Event.h:669
OutputModuleCommunicatorT.h
edm::ExceptionToActionTable
Definition: ExceptionActions.h:16
edm::maker::ModuleHolderT::moduleDescription
ModuleDescription const & moduleDescription() const override
Definition: ModuleHolder.h:66
edm::PreallocationConfiguration
Definition: PreallocationConfiguration.h:27
edm::maker::ModuleHolder::replaceModuleFor
virtual void replaceModuleFor(Worker *) const =0
eostools.move
def move(src, dest)
Definition: eostools.py:511
edm::maker::ModuleHolder::registerProductsAndCallbacks
virtual void registerProductsAndCallbacks(ProductRegistry *)=0
edm::maker::ModuleHolderT::createOutputModuleCommunicator
std::unique_ptr< OutputModuleCommunicator > createOutputModuleCommunicator() override
Definition: ModuleHolder.h:74
actions
roAction_t actions[nactions]
Definition: GenABIO.cc:181
edm::maker::ModuleHolder::makeWorker
std::unique_ptr< Worker > makeWorker(ExceptionToActionTable const *actions) const
Definition: ModuleHolder.cc:21
edm::maker::ModuleHolderT::registerProductsAndCallbacks
void registerProductsAndCallbacks(ProductRegistry *iReg) override
Definition: ModuleHolder.h:70
edm::OutputModuleCommunicatorT
Definition: OutputModuleBase.h:56