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;
15  }
16 
18 
20  {
22  }
23 
24  Factory::Factory(): makers_()
25 
26  {
27  }
28 
30  {
31  return &singleInstance_;
32  }
33 
34  std::auto_ptr<Worker> Factory::makeWorker(const WorkerParams& p,
35  sigc::signal<void, const ModuleDescription&>& pre,
36  sigc::signal<void, const ModuleDescription&>& post) const
37  {
38  std::string modtype = p.pset_->getParameter<std::string>("@module_type");
39  FDEBUG(1) << "Factory: module_type = " << modtype << std::endl;
40  MakerMap::iterator it = makers_.find(modtype);
41 
42  if(it == makers_.end())
43  {
44  std::auto_ptr<Maker> wm(MakerPluginFactory::get()->create(modtype));
45 
46  if(wm.get()==0)
47  throw edm::Exception(errors::Configuration,"UnknownModule")
48  << "Module " << modtype
49  << " with version " << p.processConfiguration_->releaseVersion()
50  << " was not registered.\n"
51  << "Perhaps your module type is misspelled or is not a "
52  << "framework plugin.\n"
53  << "Try running EdmPluginDump to obtain a list of "
54  << "available Plugins.";
55 
56  FDEBUG(1) << "Factory: created worker of type " << modtype << std::endl;
57 
58  std::pair<MakerMap::iterator,bool> ret =
59  makers_.insert(std::pair<std::string,Maker*>(modtype,wm.get()));
60 
61  // if(ret.second==false)
62  // throw runtime_error("Worker Factory map insert failed");
63 
64  it = ret.first;
65  wm.release();
66  }
67 
68  std::auto_ptr<Worker> w(it->second->makeWorker(p,pre,post));
69  return w;
70  }
71 
72 }
T getParameter(std::string const &) const
ParameterSet * pset_
Definition: WorkerParams.h:38
static void cleanup(const Factory::MakerMap::value_type &v)
Definition: Factory.cc:12
#define FDEBUG(lev)
Definition: DebugMacros.h:18
Func for_all(ForwardSequence &s, Func f)
wrapper for std::for_each
Definition: Algorithms.h:16
static Factory * get()
Definition: Factory.cc:29
Container::value_type value_type
#define EDM_REGISTER_PLUGINFACTORY(_factory_, _category_)
std::auto_ptr< Worker > makeWorker(const WorkerParams &, sigc::signal< void, const ModuleDescription & > &pre, sigc::signal< void, const ModuleDescription & > &post) const
Definition: Factory.cc:34
boost::shared_ptr< ProcessConfiguration const > processConfiguration_
Definition: WorkerParams.h:40
SurfaceDeformation * create(int type, const std::vector< double > &params)
mathSSE::Vec4< T > v
T get(const Candidate &c)
Definition: component.h:56
T w() const
static Factory singleInstance_
Definition: Factory.h:33
MakerMap makers_
Definition: Factory.h:34