CMS 3D CMS Logo

List of all members | Public Types | Public Member Functions | Private Attributes
DDLElementRegistry Class Reference

The main class for processing parsed elements. More...

#include <DDLElementRegistry.h>

Public Types

typedef std::map< std::string, std::shared_ptr< DDXMLElement > > RegistryMap
 

Public Member Functions

 DDLElementRegistry ()
 
ClhepEvaluatorevaluator ()
 
std::shared_ptr< DDXMLElementgetElement (const std::string &name)
 THE most important part. Getting the pointer to a given element type. More...
 
void registerElement (const std::string &name, DDXMLElement *)
 This allows other Elements to register themselves with the static registry. More...
 
 ~DDLElementRegistry ()
 

Private Attributes

RegistryMap registry_
 

Detailed Description

The main class for processing parsed elements.

This class is designed to serve as a registry of all DDL XML elements.

This class is responsible for constructing and destructing any necessary DDL element.

Definition at line 25 of file DDLElementRegistry.h.

Member Typedef Documentation

typedef std::map<std::string, std::shared_ptr<DDXMLElement> > DDLElementRegistry::RegistryMap

Definition at line 29 of file DDLElementRegistry.h.

Constructor & Destructor Documentation

DDLElementRegistry::DDLElementRegistry ( void  )

Definition at line 43 of file DDLElementRegistry.cc.

44 {}
DDLElementRegistry::~DDLElementRegistry ( void  )

Definition at line 46 of file DDLElementRegistry.cc.

References registry_.

47 {
48  registry_.clear();
49 }

Member Function Documentation

ClhepEvaluator& DDLElementRegistry::evaluator ( )
inline
std::shared_ptr< DDXMLElement > DDLElementRegistry::getElement ( const std::string &  name)

THE most important part. Getting the pointer to a given element type.

If this is called with a DDXMLElementRegistry pointer, it will simply return a pointer if already registered or NULL, no instantiating.

Definition at line 52 of file DDLElementRegistry.cc.

References dataset::name, and registry_.

Referenced by DDLBooleanSolid::dumpBooleanSolid(), DDLPgonGenerator::preProcessElement(), DDLReflectionSolid::preProcessElement(), DDLRotationSequence::preProcessElement(), DDLAlgorithm::preProcessElement(), DDLShapelessSolid::preProcessElement(), DDLBooleanSolid::preProcessElement(), DDLPosPart::preProcessElement(), DDLPolyGenerator::preProcessElement(), DDLCompositeMaterial::preProcessElement(), DDLLogicalPart::preProcessElement(), DDLPgonGenerator::processElement(), DDLReflectionSolid::processElement(), DDLRotationSequence::processElement(), DDLSpecPar::processElement(), DDLRotationByAxis::processElement(), DDLAlgorithm::processElement(), DDLPosPart::processElement(), DDLPolyGenerator::processElement(), DDLBooleanSolid::processElement(), DDLCompositeMaterial::processElement(), DDLLogicalPart::processElement(), DDLMaterial::setReference(), and DDLSolid::setReference().

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

This allows other Elements to register themselves with the static registry.

Member Data Documentation

RegistryMap DDLElementRegistry::registry_
private

Definition at line 49 of file DDLElementRegistry.h.

Referenced by getElement(), and ~DDLElementRegistry().