CMS 3D CMS Logo

Factory.cc
Go to the documentation of this file.
1 
6 
7 #include <iostream>
8 
10 namespace edm {
11 
12  static void cleanup(const Factory::MakerMap::value_type& v) { delete v.second.get(); }
13 
14  Factory const Factory::singleInstance_;
15 
17 
19  : makers_()
20 
21  {}
22 
23  Factory const* Factory::get() { return &singleInstance_; }
24 
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  }
54 
55  std::shared_ptr<maker::ModuleHolder> Factory::makeModule(
56  const MakeModuleParams& p,
57  signalslot::Signal<void(const ModuleDescription&)>& pre,
58  signalslot::Signal<void(const ModuleDescription&)>& post) const {
59  auto maker = findMaker(p);
60  auto mod(maker->makeModule(p, pre, post));
61  return mod;
62  }
63 
64  std::shared_ptr<maker::ModuleHolder> Factory::makeReplacementModule(const edm::ParameterSet& p) const {
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  }
72 } // namespace edm
runTheMatrix.ret
ret
prodAgent to be discontinued
Definition: runTheMatrix.py:542
edm::Factory
Definition: Factory.h:19
edm::Factory::Factory
Factory()
Definition: Factory.cc:18
edm::Maker
Definition: WorkerMaker.h:22
edm
HLT enums.
Definition: AlignableModifier.h:19
AlCaHLTBitMon_ParallelJobs.p
p
Definition: AlCaHLTBitMon_ParallelJobs.py:153
mod
T mod(const T &a, const T &b)
Definition: ecalDccMap.h:4
Algorithms.h
edm::Factory::~Factory
~Factory()
Definition: Factory.cc:16
edm::MakeModuleParams
Definition: MakeModuleParams.h:21
beamerCreator.create
def create(alignables, pedeDump, additionalData, outputFile, config)
Definition: beamerCreator.py:44
findQualityFiles.v
v
Definition: findQualityFiles.py:179
edm::Factory::makeReplacementModule
std::shared_ptr< maker::ModuleHolder > makeReplacementModule(const edm::ParameterSet &) const
Definition: Factory.cc:64
edm::ModuleDescription
Definition: ModuleDescription.h:21
edm::Exception
Definition: EDMException.h:77
edm::for_all
Func for_all(ForwardSequence &s, Func f)
wrapper for std::for_each
Definition: Algorithms.h:14
EDMException.h
edm::Factory::findMaker
Maker * findMaker(const MakeModuleParams &p) const
Definition: Factory.cc:25
EDM_REGISTER_PLUGINFACTORY
#define EDM_REGISTER_PLUGINFACTORY(_factory_, _category_)
Definition: PluginFactory.h:89
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
edm::Factory::singleInstance_
static const Factory singleInstance_
Definition: Factory.h:37
edm::ParameterSet
Definition: ParameterSet.h:47
FDEBUG
#define FDEBUG(lev)
Definition: DebugMacros.h:19
edmplugin::PluginFactory
Definition: PluginFactory.h:34
edm::Factory::makeModule
std::shared_ptr< maker::ModuleHolder > makeModule(const MakeModuleParams &, signalslot::Signal< void(const ModuleDescription &)> &pre, signalslot::Signal< void(const ModuleDescription &)> &post) const
Definition: Factory.cc:55
reco::JetExtendedAssociation::value_type
Container::value_type value_type
Definition: JetExtendedAssociation.h:30
get
#define get
edm::Factory::get
static Factory const * get()
Definition: Factory.cc:23
DebugMacros.h
edm::Factory::makers_
MakerMap makers_
Definition: Factory.h:39
Factory.h
edm::signalslot::Signal
Definition: DelayedReader.h:26
edm::errors::Configuration
Definition: EDMException.h:36
edm::cleanup
static void cleanup(const Factory::MakerMap::value_type &v)
Definition: Factory.cc:12