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 
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
T getParameter(std::string const &) const
#define EDM_REGISTER_PLUGINFACTORY(_factory_, _category_)
Definition: PluginFactory.h:89
def create(alignables, pedeDump, additionalData, outputFile, config)
ret
prodAgent to be discontinued
static void cleanup(const Factory::MakerMap::value_type &v)
Definition: Factory.cc:12
std::shared_ptr< maker::ModuleHolder > makeReplacementModule(const edm::ParameterSet &) const
Definition: Factory.cc:64
Maker * findMaker(const MakeModuleParams &p) const
Definition: Factory.cc:25
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
Func for_all(ForwardSequence &s, Func f)
wrapper for std::for_each
Definition: Algorithms.h:14
static Factory const singleInstance_
Definition: Factory.h:35
static Factory const * get()
Definition: Factory.cc:23
HLT enums.
#define FDEBUG(lev)
Definition: DebugMacros.h:19
T mod(const T &a, const T &b)
Definition: ecalDccMap.h:4
std::shared_ptr< ProcessConfiguration const > processConfiguration_
MakerMap makers_
Definition: Factory.h:36