CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
ComponentFactoryByName.h
Go to the documentation of this file.
1 #ifndef SimG4Core_ComponentFactoryByName_H
2 #define SimG4Core_ComponentFactoryByName_H
3 
5 
6 #include <string>
7 #include <map>
8 
9 template <class B>
11 {
12 public:
13  static B * getBuilder(const std::string & name)
14  {
15  if (myMap().size() == 0)
16  throw SimG4Exception("No Builder registered to the Factory.");
17  if (myMap().find(name) == myMap().end())
18  throw SimG4Exception("The Component "+name+" is not registered to the Factory.");
19  return (myMap()[name]);
20  }
21  static void setBuilder(B * in , const std::string & name)
22  {
23  if (name.empty())
24  throw SimG4Exception("The registration of Components without name is not allowed.");
25  myMap()[name] = in;
26  }
27  typedef std::map<std::string,B *> BuilderMapType;
28 protected:
29  static BuilderMapType & myMap()
30  {
31  static BuilderMapType me_;
32  return me_;
33  }
34 };
35 
36 #endif
37 
38 
39 
static B * getBuilder(const std::string &name)
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:7
static BuilderMapType & myMap()
#define end
Definition: vmac.h:37
std::map< std::string, B * > BuilderMapType
static void setBuilder(B *in, const std::string &name)
tuple size
Write out results.