CMS 3D CMS Logo

List of all members | Public Types | Public Member Functions | Static Public Member Functions | Private Member Functions | Private Attributes | Static Private Attributes
edm::Factory Class Reference

#include <Factory.h>

Public Types

typedef std::map< std::string, edm::propagate_const< Maker * > > MakerMap
 

Public Member Functions

std::shared_ptr< maker::ModuleHoldermakeModule (const MakeModuleParams &, signalslot::Signal< void(const ModuleDescription &)> &pre, signalslot::Signal< void(const ModuleDescription &)> &post) const
 
std::shared_ptr< maker::ModuleHoldermakeReplacementModule (const edm::ParameterSet &) const
 
 ~Factory ()
 

Static Public Member Functions

static Factory const * get ()
 

Private Member Functions

 Factory ()
 
MakerfindMaker (const MakeModuleParams &p) const
 

Private Attributes

MakerMap makers_
 

Static Private Attributes

static Factory const singleInstance_
 

Detailed Description

Definition at line 18 of file Factory.h.

Member Typedef Documentation

typedef std::map<std::string, edm::propagate_const<Maker*> > edm::Factory::MakerMap

Definition at line 21 of file Factory.h.

Constructor & Destructor Documentation

edm::Factory::~Factory ( )

Definition at line 19 of file Factory.cc.

References edm::cleanup(), edm::for_all(), and makers_.

20  {
22  }
static void cleanup(const Factory::MakerMap::value_type &v)
Definition: Factory.cc:12
Func for_all(ForwardSequence &s, Func f)
wrapper for std::for_each
Definition: Algorithms.h:16
MakerMap makers_
Definition: Factory.h:38
edm::Factory::Factory ( )
private

Definition at line 24 of file Factory.cc.

24  : makers_()
25 
26  {
27  }
MakerMap makers_
Definition: Factory.h:38

Member Function Documentation

Maker * edm::Factory::findMaker ( const MakeModuleParams p) const
private

Definition at line 34 of file Factory.cc.

References edm::errors::Configuration, beamerCreator::create(), FDEBUG, reco::get(), edm::ParameterSet::getParameter(), makers_, edm::MakeModuleParams::processConfiguration_, edm::MakeModuleParams::pset_, and AlCaHLTBitMon_QueryRunRegistry::string.

Referenced by makeModule().

35  {
36  std::string modtype = p.pset_->getParameter<std::string>("@module_type");
37  FDEBUG(1) << "Factory: module_type = " << modtype << std::endl;
38  MakerMap::iterator it = makers_.find(modtype);
39 
40  if(it == makers_.end())
41  {
42  std::unique_ptr<Maker> wm(MakerPluginFactory::get()->create(modtype));
43 
44  if(wm.get()==nullptr)
45  throw edm::Exception(errors::Configuration,"UnknownModule")
46  << "Module " << modtype
47  << " with version " << p.processConfiguration_->releaseVersion()
48  << " was not registered.\n"
49  << "Perhaps your module type is misspelled or is not a "
50  << "framework plugin.\n"
51  << "Try running EdmPluginDump to obtain a list of "
52  << "available Plugins.";
53 
54  FDEBUG(1) << "Factory: created worker of type " << modtype << std::endl;
55 
56  std::pair<MakerMap::iterator,bool> ret =
57  makers_.insert(std::pair<std::string,Maker*>(modtype,wm.get()));
58 
59  // if(ret.second==false)
60  // throw runtime_error("Worker Factory map insert failed");
61 
62  it = ret.first;
63  wm.release();
64  }
65  return it->second;
66  }
def create(alignables, pedeDump, additionalData, outputFile, config)
#define FDEBUG(lev)
Definition: DebugMacros.h:20
T get(const Candidate &c)
Definition: component.h:55
MakerMap makers_
Definition: Factory.h:38
Factory const * edm::Factory::get ( )
static
std::shared_ptr< maker::ModuleHolder > edm::Factory::makeModule ( const MakeModuleParams p,
signalslot::Signal< void(const ModuleDescription &)> &  pre,
signalslot::Signal< void(const ModuleDescription &)> &  post 
) const

Definition at line 68 of file Factory.cc.

References findMaker(), and mod().

Referenced by edm::ModuleRegistry::getModule().

71  {
72  auto maker = findMaker(p);
73  auto mod(maker->makeModule(p,pre,post));
74  return mod;
75  }
Maker * findMaker(const MakeModuleParams &p) const
Definition: Factory.cc:34
T mod(const T &a, const T &b)
Definition: ecalDccMap.h:4
std::shared_ptr< maker::ModuleHolder > edm::Factory::makeReplacementModule ( const edm::ParameterSet p) const

Definition at line 77 of file Factory.cc.

References edm::ParameterSet::getParameter(), makers_, and AlCaHLTBitMon_QueryRunRegistry::string.

Referenced by edm::ModuleRegistry::replaceModule().

78  {
79  std::string modtype = p.getParameter<std::string>("@module_type");
80  MakerMap::iterator it = makers_.find(modtype);
81  if(it != makers_.end()) {
82  return it->second->makeReplacementModule(p);
83  }
84  return std::shared_ptr<maker::ModuleHolder>{};
85  }
T getParameter(std::string const &) const
MakerMap makers_
Definition: Factory.h:38

Member Data Documentation

MakerMap edm::Factory::makers_
mutableprivate

Definition at line 38 of file Factory.h.

Referenced by findMaker(), makeReplacementModule(), and ~Factory().

Factory const edm::Factory::singleInstance_
staticprivate

Definition at line 37 of file Factory.h.

Referenced by edm::cleanup(), and get().