CMS 3D CMS Logo

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 cms::Exception("SimG4CoreNotification", " ComponentFactoryByName::getBuilder: No Builder registered to the Factory.");
17  }
18  if (myMap().find(name) == myMap().end()) {
19  throw cms::Exception("SimG4CoreNotification", " ComponentFactoryByName::getBuilder: The Component "+name+" is not registered to the Factory.");
20  }
21  return (myMap()[name]);
22  }
23  static void setBuilder(B * in , const std::string & name)
24  {
25  if (name.empty()) {
26  throw cms::Exception("SimG4CoreNotification", " ComponentFactoryByName::setBuilder: The registration of Components without name is not allowed.");
27  }
28  myMap()[name] = in;
29  }
30  typedef std::map<std::string,B *> BuilderMapType;
31 protected:
32  static BuilderMapType & myMap()
33  {
34  static BuilderMapType me_;
35  return me_;
36  }
37 };
38 
39 #endif
40 
41 
42 
spr::find
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:19
ComponentFactoryByName::myMap
static BuilderMapType & myMap()
Definition: ComponentFactoryByName.h:32
mps_fire.end
end
Definition: mps_fire.py:242
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
recoMuon::in
Definition: RecoMuonEnumerators.h:6
ComponentFactoryByName::getBuilder
static B * getBuilder(const std::string &name)
Definition: ComponentFactoryByName.h:13
TtFullHadDaughter::B
static const std::string B
Definition: TtFullHadronicEvent.h:9
ComponentFactoryByName
Definition: ComponentFactoryByName.h:10
Exception
Definition: hltDiff.cc:246
Skims_PA_cff.name
name
Definition: Skims_PA_cff.py:17
Exception.h
ComponentFactoryByName::setBuilder
static void setBuilder(B *in, const std::string &name)
Definition: ComponentFactoryByName.h:23
ComponentFactoryByName::BuilderMapType
std::map< std::string, B * > BuilderMapType
Definition: ComponentFactoryByName.h:30
findQualityFiles.size
size
Write out results.
Definition: findQualityFiles.py:443