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

ClhepEvaluator evaluator_
 
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 23 of file DDLElementRegistry.h.

Member Typedef Documentation

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

Definition at line 27 of file DDLElementRegistry.h.

Constructor & Destructor Documentation

DDLElementRegistry::DDLElementRegistry ( void  )

Definition at line 38 of file DDLElementRegistry.cc.

39 {}
DDLElementRegistry::~DDLElementRegistry ( void  )

Definition at line 41 of file DDLElementRegistry.cc.

References registry_.

42 {
43  registry_.clear();
44 }

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 47 of file DDLElementRegistry.cc.

References dataset::name, and registry_.

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

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 }
void DDLElementRegistry::registerElement ( const std::string &  name,
DDXMLElement  
)

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

Member Data Documentation

ClhepEvaluator DDLElementRegistry::evaluator_
private

Definition at line 48 of file DDLElementRegistry.h.

Referenced by evaluator().

RegistryMap DDLElementRegistry::registry_
private

Definition at line 47 of file DDLElementRegistry.h.

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