Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:05:32

0001 #include "DetectorDescription/Parser/interface/DDLElementRegistry.h"
0002 #include "DetectorDescription/Parser/src/DDLAlgorithm.h"
0003 #include "DetectorDescription/Parser/src/DDLAssembly.h"
0004 #include "DetectorDescription/Parser/src/DDLBooleanSolid.h"
0005 #include "DetectorDescription/Parser/src/DDLBox.h"
0006 #include "DetectorDescription/Parser/src/DDLCompositeMaterial.h"
0007 #include "DetectorDescription/Parser/src/DDLCone.h"
0008 #include "DetectorDescription/Parser/src/DDLDivision.h"
0009 #include "DetectorDescription/Parser/src/DDLElementaryMaterial.h"
0010 #include "DetectorDescription/Parser/src/DDLEllipticalTube.h"
0011 #include "DetectorDescription/Parser/src/DDLLogicalPart.h"
0012 #include "DetectorDescription/Parser/src/DDLMap.h"
0013 #include "DetectorDescription/Parser/src/DDLNumeric.h"
0014 #include "DetectorDescription/Parser/src/DDLPolyGenerator.h"
0015 #include "DetectorDescription/Parser/src/DDLPgonGenerator.h"
0016 #include "DetectorDescription/Parser/src/DDLPosPart.h"
0017 #include "DetectorDescription/Parser/src/DDLPseudoTrap.h"
0018 #include "DetectorDescription/Parser/src/DDLRotationAndReflection.h"
0019 #include "DetectorDescription/Parser/src/DDLRotationByAxis.h"
0020 #include "DetectorDescription/Parser/src/DDLRotationSequence.h"
0021 #include "DetectorDescription/Parser/src/DDLShapelessSolid.h"
0022 #include "DetectorDescription/Parser/src/DDLSpecPar.h"
0023 #include "DetectorDescription/Parser/src/DDLSphere.h"
0024 #include "DetectorDescription/Parser/src/DDLString.h"
0025 #include "DetectorDescription/Parser/src/DDLTorus.h"
0026 #include "DetectorDescription/Parser/src/DDLTrapezoid.h"
0027 #include "DetectorDescription/Parser/src/DDLTubs.h"
0028 #include "DetectorDescription/Parser/src/DDLVector.h"
0029 #include "DetectorDescription/Parser/src/DDXMLElement.h"
0030 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0031 
0032 #include <cstddef>
0033 #include <algorithm>
0034 #include <map>
0035 #include <string>
0036 #include <utility>
0037 #include <vector>
0038 
0039 DDLElementRegistry::DDLElementRegistry(void) {}
0040 
0041 DDLElementRegistry::~DDLElementRegistry(void) { registry_.clear(); }
0042 
0043 std::shared_ptr<DDXMLElement> DDLElementRegistry::getElement(const std::string& name) {
0044   RegistryMap::iterator it = registry_.find(name);
0045   std::shared_ptr<DDXMLElement> myret(nullptr);
0046   if (it != registry_.end()) {
0047     return it->second;
0048   } else {
0049     // Make the Solid handlers and register them.
0050     if (name == "Box") {
0051       myret = std::make_shared<DDLBox>(this);
0052     } else if (name == "Cone") {
0053       myret = std::make_shared<DDLCone>(this);
0054     } else if (name == "Polyhedra" || name == "Polycone") {
0055       myret = std::make_shared<DDLPolyGenerator>(this);
0056     } else if (name == "Trapezoid" || name == "Trd1") {
0057       myret = std::make_shared<DDLTrapezoid>(this);
0058     } else if (name == "PseudoTrap") {
0059       myret = std::make_shared<DDLPseudoTrap>(this);
0060     } else if (name == "Tubs" || name == "CutTubs" || name == "Tube" || name == "TruncTubs") {
0061       myret = std::make_shared<DDLTubs>(this);
0062     } else if (name == "Torus") {
0063       myret = std::make_shared<DDLTorus>(this);
0064     } else if (name == "UnionSolid" || name == "SubtractionSolid" || name == "IntersectionSolid") {
0065       myret = std::make_shared<DDLBooleanSolid>(this);
0066     } else if (name == "ShapelessSolid") {
0067       myret = std::make_shared<DDLShapelessSolid>(this);
0068     } else if (name == "Sphere") {
0069       myret = std::make_shared<DDLSphere>(this);
0070     } else if (name == "EllipticalTube") {
0071       myret = std::make_shared<DDLEllipticalTube>(this);
0072     } else if (name == "ExtrudedPolygon") {
0073       myret = std::make_shared<DDLPgonGenerator>(this);
0074     } else if (name == "Assembly")
0075       myret = std::make_shared<DDLAssembly>(this);
0076 
0077     //  LogicalParts, Positioners, Materials, Rotations, Reflections
0078     //  and Specific (Specified?) Parameters
0079     else if (name == "PosPart") {
0080       myret = std::make_shared<DDLPosPart>(this);
0081     } else if (name == "CompositeMaterial") {
0082       myret = std::make_shared<DDLCompositeMaterial>(this);
0083     } else if (name == "ElementaryMaterial") {
0084       myret = std::make_shared<DDLElementaryMaterial>(this);
0085     } else if (name == "LogicalPart") {
0086       myret = std::make_shared<DDLLogicalPart>(this);
0087     } else if (name == "ReflectionRotation" || name == "Rotation") {
0088       myret = std::make_shared<DDLRotationAndReflection>(this);
0089     } else if (name == "SpecPar") {
0090       myret = std::make_shared<DDLSpecPar>(this);
0091     } else if (name == "RotationSequence") {
0092       myret = std::make_shared<DDLRotationSequence>(this);
0093     } else if (name == "RotationByAxis") {
0094       myret = std::make_shared<DDLRotationByAxis>(this);
0095     }
0096     // Special, need them around.
0097     else if (name == "SpecParSection") {
0098       myret = std::make_shared<DDXMLElement>(this, true);
0099     } else if (name == "Vector") {
0100       myret = std::make_shared<DDLVector>(this);
0101     } else if (name == "Map") {
0102       myret = std::make_shared<DDLMap>(this);
0103     } else if (name == "String") {
0104       myret = std::make_shared<DDLString>(this);
0105     } else if (name == "Numeric") {
0106       myret = std::make_shared<DDLNumeric>(this);
0107     } else if (name == "Algorithm") {
0108       myret = std::make_shared<DDLAlgorithm>(this);
0109     } else if (name == "Division") {
0110       myret = std::make_shared<DDLDivision>(this);
0111     }
0112 
0113     // Supporting Cast of elements.
0114     //  All elements which simply accumulate attributes which are then used
0115     //  by one of the above elements.
0116     else if (name == "MaterialFraction" || name == "RZPoint" || name == "XYPoint" || name == "PartSelector" ||
0117              name == "Parameter" || name == "ZSection" || name == "ZXYSection" || name == "Translation" ||
0118              name == "rSolid" || name == "rMaterial" || name == "rParent" || name == "rChild" || name == "rRotation" ||
0119              name == "rReflectionRotation" || name == "DDDefinition") {
0120       myret = std::make_shared<DDXMLElement>(this);
0121     }
0122 
0123     //  IF it is a new element return a default XMLElement which processes nothing.
0124     //  Since there are elements in the XML which require no processing, they
0125     //  can all use the same DDXMLElement which defaults to anything.  A validated
0126     //  XML document (i.e. validated with XML Schema) will work properly.
0127     //  As of 8/16/2002:  Elements like LogicalPartSection and any other *Section
0128     //  XML elements of the DDLSchema are taken care of by this.
0129     else {
0130       myret = std::make_shared<DDXMLElement>(this);
0131     }
0132 
0133     // Actually register the thing
0134     registry_[name] = myret;
0135   }
0136   return myret;
0137 }