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 20 of file Factory.h.

Constructor & Destructor Documentation

edm::Factory::~Factory ( )

Definition at line 16 of file Factory.cc.

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

16 { for_all(makers_, cleanup); }
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:14
MakerMap makers_
Definition: Factory.h:36
edm::Factory::Factory ( )
private

Definition at line 18 of file Factory.cc.

19  : makers_()
20 
21  {}
MakerMap makers_
Definition: Factory.h:36

Member Function Documentation

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

Definition at line 25 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().

25  {
26  std::string modtype = p.pset_->getParameter<std::string>("@module_type");
27  FDEBUG(1) << "Factory: module_type = " << modtype << std::endl;
28  MakerMap::iterator it = makers_.find(modtype);
29 
30  if (it == makers_.end()) {
31  std::unique_ptr<Maker> wm(MakerPluginFactory::get()->create(modtype));
32 
33  if (wm.get() == nullptr)
34  throw edm::Exception(errors::Configuration, "UnknownModule")
35  << "Module " << modtype << " with version " << p.processConfiguration_->releaseVersion()
36  << " was not registered.\n"
37  << "Perhaps your module type is misspelled or is not a "
38  << "framework plugin.\n"
39  << "Try running EdmPluginDump to obtain a list of "
40  << "available Plugins.";
41 
42  FDEBUG(1) << "Factory: created worker of type " << modtype << std::endl;
43 
44  std::pair<MakerMap::iterator, bool> ret = makers_.insert(std::pair<std::string, Maker*>(modtype, wm.get()));
45 
46  // if(ret.second==false)
47  // throw runtime_error("Worker Factory map insert failed");
48 
49  it = ret.first;
50  wm.release();
51  }
52  return it->second;
53  }
def create(alignables, pedeDump, additionalData, outputFile, config)
#define FDEBUG(lev)
Definition: DebugMacros.h:19
T get(const Candidate &c)
Definition: component.h:55
MakerMap makers_
Definition: Factory.h:36
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 55 of file Factory.cc.

References findMaker(), and mod().

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

58  {
59  auto maker = findMaker(p);
60  auto mod(maker->makeModule(p, pre, post));
61  return mod;
62  }
Maker * findMaker(const MakeModuleParams &p) const
Definition: Factory.cc:25
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 64 of file Factory.cc.

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

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

64  {
65  std::string modtype = p.getParameter<std::string>("@module_type");
66  MakerMap::iterator it = makers_.find(modtype);
67  if (it != makers_.end()) {
68  return it->second->makeReplacementModule(p);
69  }
70  return std::shared_ptr<maker::ModuleHolder>{};
71  }
T getParameter(std::string const &) const
MakerMap makers_
Definition: Factory.h:36

Member Data Documentation

MakerMap edm::Factory::makers_
mutableprivate

Definition at line 36 of file Factory.h.

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

Factory const edm::Factory::singleInstance_
staticprivate

Definition at line 35 of file Factory.h.

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