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

◆ RegistryMap

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

Definition at line 25 of file DDLElementRegistry.h.

Constructor & Destructor Documentation

◆ DDLElementRegistry()

DDLElementRegistry::DDLElementRegistry ( void  )

Definition at line 39 of file DDLElementRegistry.cc.

39 {}

◆ ~DDLElementRegistry()

DDLElementRegistry::~DDLElementRegistry ( void  )

Definition at line 41 of file DDLElementRegistry.cc.

References registry_.

41 { registry_.clear(); }

Member Function Documentation

◆ evaluator()

ClhepEvaluator& DDLElementRegistry::evaluator ( )
inline

◆ getElement()

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

References ALPAKA_ACCELERATOR_NAMESPACE::vertexFinder::it, Skims_PA_cff::name, and registry_.

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

43  {
44  RegistryMap::iterator it = registry_.find(name);
45  std::shared_ptr<DDXMLElement> myret(nullptr);
46  if (it != registry_.end()) {
47  return it->second;
48  } else {
49  // Make the Solid handlers and register them.
50  if (name == "Box") {
51  myret = std::make_shared<DDLBox>(this);
52  } else if (name == "Cone") {
53  myret = std::make_shared<DDLCone>(this);
54  } else if (name == "Polyhedra" || name == "Polycone") {
55  myret = std::make_shared<DDLPolyGenerator>(this);
56  } else if (name == "Trapezoid" || name == "Trd1") {
57  myret = std::make_shared<DDLTrapezoid>(this);
58  } else if (name == "PseudoTrap") {
59  myret = std::make_shared<DDLPseudoTrap>(this);
60  } else if (name == "Tubs" || name == "CutTubs" || name == "Tube" || name == "TruncTubs") {
61  myret = std::make_shared<DDLTubs>(this);
62  } else if (name == "Torus") {
63  myret = std::make_shared<DDLTorus>(this);
64  } else if (name == "UnionSolid" || name == "SubtractionSolid" || name == "IntersectionSolid") {
65  myret = std::make_shared<DDLBooleanSolid>(this);
66  } else if (name == "ShapelessSolid") {
67  myret = std::make_shared<DDLShapelessSolid>(this);
68  } else if (name == "Sphere") {
69  myret = std::make_shared<DDLSphere>(this);
70  } else if (name == "EllipticalTube") {
71  myret = std::make_shared<DDLEllipticalTube>(this);
72  } else if (name == "ExtrudedPolygon") {
73  myret = std::make_shared<DDLPgonGenerator>(this);
74  } else if (name == "Assembly")
75  myret = std::make_shared<DDLAssembly>(this);
76 
77  // LogicalParts, Positioners, Materials, Rotations, Reflections
78  // and Specific (Specified?) Parameters
79  else if (name == "PosPart") {
80  myret = std::make_shared<DDLPosPart>(this);
81  } else if (name == "CompositeMaterial") {
82  myret = std::make_shared<DDLCompositeMaterial>(this);
83  } else if (name == "ElementaryMaterial") {
84  myret = std::make_shared<DDLElementaryMaterial>(this);
85  } else if (name == "LogicalPart") {
86  myret = std::make_shared<DDLLogicalPart>(this);
87  } else if (name == "ReflectionRotation" || name == "Rotation") {
88  myret = std::make_shared<DDLRotationAndReflection>(this);
89  } else if (name == "SpecPar") {
90  myret = std::make_shared<DDLSpecPar>(this);
91  } else if (name == "RotationSequence") {
92  myret = std::make_shared<DDLRotationSequence>(this);
93  } else if (name == "RotationByAxis") {
94  myret = std::make_shared<DDLRotationByAxis>(this);
95  }
96  // Special, need them around.
97  else if (name == "SpecParSection") {
98  myret = std::make_shared<DDXMLElement>(this, true);
99  } else if (name == "Vector") {
100  myret = std::make_shared<DDLVector>(this);
101  } else if (name == "Map") {
102  myret = std::make_shared<DDLMap>(this);
103  } else if (name == "String") {
104  myret = std::make_shared<DDLString>(this);
105  } else if (name == "Numeric") {
106  myret = std::make_shared<DDLNumeric>(this);
107  } else if (name == "Algorithm") {
108  myret = std::make_shared<DDLAlgorithm>(this);
109  } else if (name == "Division") {
110  myret = std::make_shared<DDLDivision>(this);
111  }
112 
113  // Supporting Cast of elements.
114  // All elements which simply accumulate attributes which are then used
115  // by one of the above elements.
116  else if (name == "MaterialFraction" || name == "RZPoint" || name == "XYPoint" || name == "PartSelector" ||
117  name == "Parameter" || name == "ZSection" || name == "ZXYSection" || name == "Translation" ||
118  name == "rSolid" || name == "rMaterial" || name == "rParent" || name == "rChild" || name == "rRotation" ||
119  name == "rReflectionRotation" || name == "DDDefinition") {
120  myret = std::make_shared<DDXMLElement>(this);
121  }
122 
123  // IF it is a new element return a default XMLElement which processes nothing.
124  // Since there are elements in the XML which require no processing, they
125  // can all use the same DDXMLElement which defaults to anything. A validated
126  // XML document (i.e. validated with XML Schema) will work properly.
127  // As of 8/16/2002: Elements like LogicalPartSection and any other *Section
128  // XML elements of the DDLSchema are taken care of by this.
129  else {
130  myret = std::make_shared<DDXMLElement>(this);
131  }
132 
133  // Actually register the thing
134  registry_[name] = myret;
135  }
136  return myret;
137 }

◆ registerElement()

void DDLElementRegistry::registerElement ( const std::string &  name,
DDXMLElement  
)

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

Member Data Documentation

◆ evaluator_

ClhepEvaluator DDLElementRegistry::evaluator_
private

Definition at line 46 of file DDLElementRegistry.h.

Referenced by evaluator().

◆ registry_

RegistryMap DDLElementRegistry::registry_
private

Definition at line 45 of file DDLElementRegistry.h.

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