Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016 #include "DetectorDescription/Parser/src/DDLAlgorithm.h"
00017 #include "DetectorDescription/Parser/src/DDLAlgoPosPart.h"
00018 #include "DetectorDescription/Parser/src/DDLBooleanSolid.h"
00019 #include "DetectorDescription/Parser/src/DDLBox.h"
00020 #include "DetectorDescription/Parser/src/DDLCompositeMaterial.h"
00021 #include "DetectorDescription/Parser/src/DDLCone.h"
00022 #include "DetectorDescription/Parser/src/DDLDivision.h"
00023 #include "DetectorDescription/Parser/src/DDLElementaryMaterial.h"
00024 #include "DetectorDescription/Parser/src/DDLEllipticalTube.h"
00025 #include "DetectorDescription/Parser/src/DDLEllipsoid.h"
00026 #include "DetectorDescription/Parser/src/DDLLogicalPart.h"
00027 #include "DetectorDescription/Parser/src/DDLMap.h"
00028 #include "DetectorDescription/Parser/src/DDLNumeric.h"
00029 #include "DetectorDescription/Parser/src/DDLOrb.h"
00030 #include "DetectorDescription/Parser/src/DDLParallelepiped.h"
00031 #include "DetectorDescription/Parser/src/DDLPolyGenerator.h"
00032 #include "DetectorDescription/Parser/src/DDLPosPart.h"
00033 #include "DetectorDescription/Parser/src/DDLPseudoTrap.h"
00034 #include "DetectorDescription/Parser/src/DDLReflectionSolid.h"
00035 #include "DetectorDescription/Parser/src/DDLRotationByAxis.h"
00036 #include "DetectorDescription/Parser/src/DDLRotationAndReflection.h"
00037 #include "DetectorDescription/Parser/src/DDLRotationSequence.h"
00038 #include "DetectorDescription/Parser/src/DDLShapelessSolid.h"
00039 #include "DetectorDescription/Parser/src/DDLSpecPar.h"
00040 #include "DetectorDescription/Parser/src/DDLSphere.h"
00041 #include "DetectorDescription/Parser/src/DDLString.h"
00042 #include "DetectorDescription/Parser/src/DDLTorus.h"
00043 #include "DetectorDescription/Parser/src/DDLTrapezoid.h"
00044 #include "DetectorDescription/Parser/src/DDLTubs.h"
00045 #include "DetectorDescription/Parser/src/DDLVector.h"
00046
00047 #include "DetectorDescription/Base/interface/DDdebug.h"
00048 #include "DetectorDescription/Parser/interface/DDLElementRegistry.h"
00049
00050 #include <iostream>
00051
00052 DDLElementRegistry::DDLElementRegistry( void )
00053 {}
00054
00055 DDLElementRegistry::~DDLElementRegistry( void )
00056 {
00057
00058
00059 std::vector<DDXMLElement*> toDelete;
00060 for( RegistryMap::const_iterator it = registry_.begin(), end = registry_.end(); it != end; ++it )
00061 {
00062 std::vector<DDXMLElement*>::const_iterator deleteIt = std::find( toDelete.begin(), toDelete.end(), it->second );
00063 if( deleteIt == toDelete.end())
00064 {
00065 toDelete.push_back( it->second );
00066 delete it->second;
00067 }
00068 }
00069 }
00070
00071
00072
00073
00074 DDXMLElement*
00075 DDLElementRegistry::getElement( const std::string& name )
00076 {
00077 DCOUT_V('P',"myRegistry_->getElementRegistry(" << name << ")");
00078
00079
00080 RegistryMap::iterator it = registry_.find(name);
00081
00082
00083
00084
00085 DDXMLElement* myret = NULL;
00086 if( it != registry_.end())
00087 {
00088 myret = it->second;
00089 } else {
00090
00091
00092 if (name == "Box")
00093 {
00094 myret = new DDLBox(this);
00095 }
00096 else if (name == "Cone")
00097 {
00098 myret = new DDLCone(this);
00099 }
00100 else if (name == "Polyhedra" || name == "Polycone")
00101 {
00102 myret = new DDLPolyGenerator(this);
00103 }
00104 else if (name == "Trapezoid" || name == "Trd1")
00105 {
00106 myret = new DDLTrapezoid(this);
00107 }
00108 else if (name == "PseudoTrap")
00109 {
00110 myret = new DDLPseudoTrap(this);
00111 }
00112 else if (name == "Tubs" || name == "Tube" || name == "TruncTubs")
00113 {
00114 myret = new DDLTubs(this);
00115 }
00116 else if (name == "Torus")
00117 {
00118 myret = new DDLTorus(this);
00119 }
00120 else if (name == "ReflectionSolid")
00121 {
00122 myret = new DDLReflectionSolid(this);
00123 }
00124 else if (name == "UnionSolid" || name == "SubtractionSolid"
00125 || name == "IntersectionSolid")
00126 {
00127 myret = new DDLBooleanSolid(this);
00128 }
00129 else if (name == "ShapelessSolid")
00130 {
00131 myret = new DDLShapelessSolid(this);
00132 }
00133 else if (name == "Sphere")
00134 {
00135 myret = new DDLSphere(this);
00136 }
00137 else if (name == "Orb")
00138 {
00139 myret = new DDLOrb(this);
00140 }
00141 else if (name == "EllipticalTube")
00142 {
00143 myret = new DDLEllipticalTube(this);
00144 }
00145 else if (name == "Ellipsoid")
00146 {
00147 myret = new DDLEllipsoid(this);
00148 }
00149 else if (name == "Sphere")
00150 {
00151 myret = new DDLParallelepiped(this);
00152 }
00153
00154
00155
00156 else if (name == "PosPart")
00157 {
00158 myret = new DDLPosPart(this);
00159 }
00160 else if (name == "AlgoPosPart")
00161 {
00162 myret = new DDLAlgoPosPart(this);
00163 }
00164 else if (name == "CompositeMaterial")
00165 {
00166 myret = new DDLCompositeMaterial(this);
00167 }
00168 else if (name == "ElementaryMaterial")
00169 {
00170 myret = new DDLElementaryMaterial(this);
00171 }
00172 else if (name == "LogicalPart")
00173 {
00174 myret = new DDLLogicalPart(this);
00175 }
00176 else if (name == "ReflectionRotation" || name == "Rotation" )
00177 {
00178 myret = new DDLRotationAndReflection(this);
00179 }
00180 else if (name == "SpecPar")
00181 {
00182 myret = new DDLSpecPar(this);
00183 }
00184 else if (name == "RotationSequence")
00185 {
00186 myret = new DDLRotationSequence(this);
00187 }
00188 else if (name == "RotationByAxis")
00189 {
00190 myret = new DDLRotationByAxis(this);
00191 }
00192
00193 else if (name == "SpecParSection") {
00194 myret = new DDXMLElement(this, true);
00195 }
00196 else if (name == "Vector") {
00197 myret = new DDLVector(this);
00198 }
00199 else if (name == "Map") {
00200 myret = new DDLMap(this);
00201 }
00202 else if (name == "String") {
00203 myret = new DDLString(this);
00204 }
00205 else if (name == "Numeric") {
00206 myret = new DDLNumeric(this);
00207 }
00208 else if (name == "Algorithm") {
00209 myret = new DDLAlgorithm(this);
00210 }
00211 else if (name == "Division") {
00212 myret = new DDLDivision(this);
00213 }
00214
00215
00216
00217
00218 else if (name == "MaterialFraction" || name == "ParE" || name == "ParS"
00219 || name == "RZPoint" || name == "PartSelector"
00220 || name == "Parameter" || name == "ZSection"
00221 || name == "Translation"
00222 || name == "rSolid" || name == "rMaterial"
00223 || name == "rParent" || name == "rChild"
00224 || name == "rRotation" || name == "rReflectionRotation"
00225 || name == "DDDefinition" )
00226 {
00227 myret = new DDXMLElement(this);
00228 }
00229
00230
00231
00232
00233
00234
00235
00236 else
00237 {
00238
00239
00240 myret = new DDXMLElement(this);
00241
00242
00243
00244
00245
00246 }
00247
00248
00249
00250
00251 registry_[name] = myret;
00252 }
00253 return myret;
00254 }
00255
00256 const std::string&
00257 DDLElementRegistry::getElementName( DDXMLElement* theElement ) const
00258 {
00259 for( RegistryMap::const_iterator it = registry_.begin(), end = registry_.end(); it != end; ++it )
00260 if( it->second == theElement )
00261 return it->first;
00262 return registry_.find( "***" )->first;
00263 }
00264
00265 template class DDI::Singleton<DDLElementRegistry>;
00266