CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
Factory.cc
Go to the documentation of this file.
1 
7 
8 #include <iostream>
9 
11 namespace edm {
12 
13  static void cleanup(const Factory::MakerMap::value_type& v) { delete v.second.get(); }
14 
15  Factory const Factory::singleInstance_;
16 
18 
20  : makers_()
21 
22  {}
23 
24  Factory const* Factory::get() { return &singleInstance_; }
25 
27  std::string modtype = p.pset_->getParameter<std::string>("@module_type");
28  FDEBUG(1) << "Factory: module_type = " << modtype << std::endl;
29  MakerMap::iterator it = makers_.find(modtype);
30 
31  if (it == makers_.end()) {
32  std::unique_ptr<Maker> wm(MakerPluginFactory::get()->create(modtype));
33 
34  if (wm.get() == nullptr)
35  throw edm::Exception(errors::Configuration, "UnknownModule")
36  << "Module " << modtype << " with version " << p.processConfiguration_->releaseVersion()
37  << " was not registered.\n"
38  << "Perhaps your module type is misspelled or is not a "
39  << "framework plugin.\n"
40  << "Try running EdmPluginDump to obtain a list of "
41  << "available Plugins.";
42 
43  FDEBUG(1) << "Factory: created worker of type " << modtype << std::endl;
44 
45  std::pair<MakerMap::iterator, bool> ret = makers_.insert(std::pair<std::string, Maker*>(modtype, wm.get()));
46 
47  // if(ret.second==false)
48  // throw runtime_error("Worker Factory map insert failed");
49 
50  it = ret.first;
51  wm.release();
52  }
53  return it->second;
54  }
55 
56  std::shared_ptr<maker::ModuleHolder> Factory::makeModule(
57  const MakeModuleParams& p,
58  signalslot::Signal<void(const ModuleDescription&)>& pre,
59  signalslot::Signal<void(const ModuleDescription&)>& post) const {
60  auto maker = findMaker(p);
61  auto mod(maker->makeModule(p, pre, post));
62  return mod;
63  }
64 
65  std::shared_ptr<maker::ModuleHolder> Factory::makeReplacementModule(const edm::ParameterSet& p) const {
66  std::string modtype = p.getParameter<std::string>("@module_type");
67  MakerMap::iterator it = makers_.find(modtype);
68  if (it != makers_.end()) {
69  return it->second->makeReplacementModule(p);
70  }
71  return std::shared_ptr<maker::ModuleHolder>{};
72  }
73 } // namespace edm
tuple ret
prodAgent to be discontinued
static void cleanup(const Factory::MakerMap::value_type &v)
Definition: Factory.cc:13
std::shared_ptr< maker::ModuleHolder > makeReplacementModule(const edm::ParameterSet &) const
Definition: Factory.cc:65
#define FDEBUG(lev)
Definition: DebugMacros.h:19
Maker * findMaker(const MakeModuleParams &p) const
Definition: Factory.cc:26
std::shared_ptr< maker::ModuleHolder > makeModule(const MakeModuleParams &, signalslot::Signal< void(const ModuleDescription &)> &pre, signalslot::Signal< void(const ModuleDescription &)> &post) const
Definition: Factory.cc:56
Func for_all(ForwardSequence &s, Func f)
wrapper for std::for_each
Definition: Algorithms.h:14
static Factory const singleInstance_
Definition: Factory.h:34
static Factory const * get()
Definition: Factory.cc:24
#define EDM_REGISTER_PLUGINFACTORY(_factory_, _category_)
Definition: PluginFactory.h:89
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
#define get
T mod(const T &a, const T &b)
Definition: ecalDccMap.h:4
std::shared_ptr< ProcessConfiguration const > processConfiguration_
MakerMap makers_
Definition: Factory.h:36