CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
Factory.cc
Go to the documentation of this file.
1 
6 
7 #include <iostream>
8 
10 namespace edm {
11 
13  {
14  delete v.second.get();
15  }
16 
17  Factory const Factory::singleInstance_;
18 
20  {
22  }
23 
24  Factory::Factory(): makers_()
25 
26  {
27  }
28 
30  {
31  return &singleInstance_;
32  }
33 
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()==0)
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  }
67 
68  std::shared_ptr<maker::ModuleHolder> Factory::makeModule(const MakeModuleParams& p,
69  signalslot::Signal<void(const ModuleDescription&)>& pre,
70  signalslot::Signal<void(const ModuleDescription&)>& post) const
71  {
72  auto maker = findMaker(p);
73  auto mod(maker->makeModule(p,pre,post));
74  return mod;
75  }
76 
77  std::shared_ptr<maker::ModuleHolder> Factory::makeReplacementModule(const edm::ParameterSet& p) const
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  }
86 }
T getParameter(std::string const &) const
tuple 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:77
#define FDEBUG(lev)
Definition: DebugMacros.h:18
Maker * findMaker(const MakeModuleParams &p) const
Definition: Factory.cc:34
std::shared_ptr< maker::ModuleHolder > makeModule(const MakeModuleParams &, signalslot::Signal< void(const ModuleDescription &)> &pre, signalslot::Signal< void(const ModuleDescription &)> &post) const
Definition: Factory.cc:68
Func for_all(ForwardSequence &s, Func f)
wrapper for std::for_each
Definition: Algorithms.h:16
static Factory const singleInstance_
Definition: Factory.h:37
static Factory const * get()
Definition: Factory.cc:29
#define EDM_REGISTER_PLUGINFACTORY(_factory_, _category_)
Definition: PluginFactory.h:90
T mod(const T &a, const T &b)
Definition: ecalDccMap.h:4
T get(const Candidate &c)
Definition: component.h:55
std::shared_ptr< ProcessConfiguration const > processConfiguration_
MakerMap makers_
Definition: Factory.h:38