CMS 3D CMS Logo

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