CMS 3D CMS Logo

DDLElementRegistry.cc
Go to the documentation of this file.
30 
31 #include <cstddef>
32 #include <algorithm>
33 #include <map>
34 #include <string>
35 #include <utility>
36 #include <vector>
37 
39 {}
40 
42 {
43  registry_.clear();
44 }
45 
46 std::shared_ptr<DDXMLElement>
48 {
49  RegistryMap::iterator it = registry_.find( name );
50  std::shared_ptr<DDXMLElement> myret( nullptr );
51  if( it != registry_.end())
52  {
53  return it->second;
54  } else {
55  // Make the Solid handlers and register them.
56  if (name == "Box")
57  {
58  myret = std::make_shared<DDLBox>(this);
59  }
60  else if (name == "Cone")
61  {
62  myret = std::make_shared<DDLCone>(this);
63  }
64  else if (name == "Polyhedra" || name == "Polycone")
65  {
66  myret = std::make_shared<DDLPolyGenerator>(this);
67  }
68  else if (name == "Trapezoid" || name == "Trd1")
69  {
70  myret = std::make_shared<DDLTrapezoid>(this);
71  }
72  else if (name == "PseudoTrap")
73  {
74  myret = std::make_shared<DDLPseudoTrap>(this);
75  }
76  else if (name == "Tubs" || name == "CutTubs" || name == "Tube" || name == "TruncTubs")
77  {
78  myret = std::make_shared<DDLTubs>(this);
79  }
80  else if (name == "Torus")
81  {
82  myret = std::make_shared<DDLTorus>(this);
83  }
84  else if (name == "UnionSolid" || name == "SubtractionSolid"
85  || name == "IntersectionSolid")
86  {
87  myret = std::make_shared<DDLBooleanSolid>(this);
88  }
89  else if (name == "ShapelessSolid")
90  {
91  myret = std::make_shared<DDLShapelessSolid>(this);
92  }
93  else if (name == "Sphere")
94  {
95  myret = std::make_shared<DDLSphere>(this);
96  }
97  else if (name == "EllipticalTube")
98  {
99  myret = std::make_shared<DDLEllipticalTube>(this);
100  }
101  else if (name == "ExtrudedPolygon")
102  myret = std::make_shared<DDLPgonGenerator>(this);
103 
104  // LogicalParts, Positioners, Materials, Rotations, Reflections
105  // and Specific (Specified?) Parameters
106  else if (name == "PosPart")
107  {
108  myret = std::make_shared<DDLPosPart>(this);
109  }
110  else if (name == "CompositeMaterial")
111  {
112  myret = std::make_shared<DDLCompositeMaterial>(this);
113  }
114  else if (name == "ElementaryMaterial")
115  {
116  myret = std::make_shared<DDLElementaryMaterial>(this);
117  }
118  else if (name == "LogicalPart")
119  {
120  myret = std::make_shared<DDLLogicalPart>(this);
121  }
122  else if (name == "ReflectionRotation" || name == "Rotation" )
123  {
124  myret = std::make_shared<DDLRotationAndReflection>(this);
125  }
126  else if (name == "SpecPar")
127  {
128  myret = std::make_shared<DDLSpecPar>(this);
129  }
130  else if (name == "RotationSequence")
131  {
132  myret = std::make_shared<DDLRotationSequence>(this);
133  }
134  else if (name == "RotationByAxis")
135  {
136  myret = std::make_shared<DDLRotationByAxis>(this);
137  }
138  // Special, need them around.
139  else if (name == "SpecParSection") {
140  myret = std::make_shared<DDXMLElement>(this, true);
141  }
142  else if (name == "Vector") {
143  myret = std::make_shared<DDLVector>(this);
144  }
145  else if (name == "Map") {
146  myret = std::make_shared<DDLMap>(this);
147  }
148  else if (name == "String") {
149  myret = std::make_shared<DDLString>(this);
150  }
151  else if (name == "Numeric") {
152  myret = std::make_shared<DDLNumeric>(this);
153  }
154  else if (name == "Algorithm") {
155  myret = std::make_shared<DDLAlgorithm>(this);
156  }
157  else if (name == "Division") {
158  myret = std::make_shared<DDLDivision>(this);
159  }
160 
161  // Supporting Cast of elements.
162  // All elements which simply accumulate attributes which are then used
163  // by one of the above elements.
164  else if (name == "MaterialFraction"
165  || name == "RZPoint" || name == "XYPoint" || name == "PartSelector"
166  || name == "Parameter" || name == "ZSection" || name == "ZXYSection"
167  || name == "Translation"
168  || name == "rSolid" || name == "rMaterial"
169  || name == "rParent" || name == "rChild"
170  || name == "rRotation" || name == "rReflectionRotation"
171  || name == "DDDefinition" )
172  {
173  myret = std::make_shared<DDXMLElement>(this);
174  }
175 
176  // IF it is a new element return a default XMLElement which processes nothing.
177  // Since there are elements in the XML which require no processing, they
178  // can all use the same DDXMLElement which defaults to anything. A validated
179  // XML document (i.e. validated with XML Schema) will work properly.
180  // As of 8/16/2002: Elements like LogicalPartSection and any other *Section
181  // XML elements of the DDLSchema are taken care of by this.
182  else
183  {
184  myret = std::make_shared<DDXMLElement>(this);
185  }
186 
187  // Actually register the thing
188  registry_[name] = myret;
189  }
190  return myret;
191 }
192 
std::shared_ptr< DDXMLElement > getElement(const std::string &name)
THE most important part. Getting the pointer to a given element type.