#include <DetectorDescription/Parser/src/DDLElementRegistry.h>
Public Member Functions | |
virtual | ~DDLElementRegistry () |
Destructor. | |
Static Public Member Functions | |
static DDXMLElement * | getElement (const std::string &name) |
THE most important part. Getting the pointer to a given element type. | |
static DDLElementRegistry * | instance () |
This makes it a singleton. | |
Protected Member Functions | |
DDLElementRegistry () | |
Private constructor for singleton. |
DDLElementRegistry.h - description ------------------- begin : Wed Oct 24 2001 email : case@ucdhep.ucdavis.edu
This class is designed to serve as a registry of all DDL XML elements. It inherits from DDXMLElementRegistry.
This class is responsible for constructing and destructing any necessary DDL element.
Definition at line 37 of file DDLElementRegistry.h.
DDLElementRegistry::~DDLElementRegistry | ( | ) | [virtual] |
DDLElementRegistry::DDLElementRegistry | ( | ) | [protected] |
DDXMLElement * DDLElementRegistry::getElement | ( | const std::string & | name | ) | [static] |
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.
Reimplemented from DDXMLElementRegistry.
Definition at line 103 of file DDLElementRegistry.cc.
References DCOUT_V, lat::endl(), instance(), NULL, and DDXMLElementRegistry::registerElement().
Referenced by DDLSAX2FileHandler::characters(), DDLBooleanSolid::dumpBooleanSolid(), DDLSAX2FileHandler::endElement(), MapPair::operator()(), MapMakeName::operator()(), MapMakeDouble::operator()(), DDLPosPart::preProcessElement(), DDLLogicalPart::preProcessElement(), DDLPolyGenerator::preProcessElement(), DDLRotationSequence::preProcessElement(), DDLShapelessSolid::preProcessElement(), DDLReflectionSolid::preProcessElement(), DDLBooleanSolid::preProcessElement(), DDLCompositeMaterial::preProcessElement(), DDLAlgorithm::preProcessElement(), DDLBooleanSolid::processElement(), DDLRotationSequence::processElement(), DDLSpecPar::processElement(), DDLCompositeMaterial::processElement(), DDLLogicalPart::processElement(), DDLReflectionSolid::processElement(), DDLPosPart::processElement(), DDLRotationByAxis::processElement(), DDLAlgorithm::processElement(), DDLAlgoPosPart::processElement(), DDLPolyGenerator::processElement(), DDLSolid::setReference(), DDLMaterial::setReference(), DDLSAX2FileHandler::startElement(), VectorMakeDouble::VectorMakeDouble(), and VectorMakeString::VectorMakeString().
00104 { 00105 DCOUT_V('P',"DDLElementRegistry::getElementRegistry(" << name << ")"); 00106 00107 DDXMLElement* myret = instance()->DDXMLElementRegistry::getElement(name); 00108 00109 if (myret == NULL) 00110 { 00111 00112 // Make the Solid handlers and register them. 00113 if (name == "Box") 00114 { 00115 myret = new DDLBox; 00116 } 00117 else if (name == "Cone") 00118 { 00119 myret = new DDLCone; 00120 } 00121 else if (name == "Polyhedra" || name == "Polycone") 00122 { 00123 myret = new DDLPolyGenerator; 00124 } 00125 else if (name == "Trapezoid" || name == "Trd1") 00126 { 00127 myret = new DDLTrapezoid; 00128 } 00129 else if (name == "PseudoTrap") 00130 { 00131 myret = new DDLPseudoTrap; 00132 } 00133 else if (name == "Tubs" || name == "Tube" || name == "TruncTubs") 00134 { 00135 myret = new DDLTubs; 00136 } 00137 else if (name == "Torus") 00138 { 00139 myret = new DDLTorus; 00140 } 00141 else if (name == "ReflectionSolid") 00142 { 00143 myret = new DDLReflectionSolid; 00144 } 00145 else if (name == "UnionSolid" || name == "SubtractionSolid" 00146 || name == "IntersectionSolid") 00147 { 00148 myret = new DDLBooleanSolid; 00149 } 00150 else if (name == "ShapelessSolid") 00151 { 00152 myret = new DDLShapelessSolid; 00153 } 00154 00155 // LogicalParts, Positioners, Materials, Rotations, Reflections 00156 // and Specific (Specified?) Parameters 00157 else if (name == "PosPart") 00158 { 00159 myret = new DDLPosPart; 00160 } 00161 else if (name == "AlgoPosPart") 00162 { 00163 myret = new DDLAlgoPosPart; 00164 } 00165 else if (name == "CompositeMaterial") 00166 { 00167 myret = new DDLCompositeMaterial; 00168 } 00169 else if (name == "ElementaryMaterial") 00170 { 00171 myret = new DDLElementaryMaterial; 00172 } 00173 else if (name == "LogicalPart") 00174 { 00175 myret = new DDLLogicalPart; 00176 } 00177 else if (name == "ReflectionRotation" || name == "Rotation" ) 00178 { 00179 myret = new DDLRotationAndReflection; 00180 } 00181 else if (name == "SpecPar") 00182 { 00183 myret = new DDLSpecPar; 00184 } 00185 else if (name == "RotationSequence") 00186 { 00187 myret = new DDLRotationSequence; 00188 } 00189 else if (name == "RotationByAxis") 00190 { 00191 myret = new DDLRotationByAxis; 00192 } 00193 // Special, need them around. 00194 else if (name == "SpecParSection") { 00195 myret = new DDXMLElement(true); 00196 } 00197 else if (name == "Vector") { 00198 myret = new DDLVector; 00199 } 00200 else if (name == "Map") { 00201 myret = new DDLMap; 00202 } 00203 else if (name == "String") { 00204 myret = new DDLString; 00205 } 00206 else if (name == "Numeric") { 00207 myret = new DDLNumeric; 00208 } 00209 else if (name == "Algorithm") { 00210 myret = new DDLAlgorithm; 00211 } 00212 else if (name == "Division") { 00213 myret = new DDLDivision; 00214 } 00215 00216 // Supporting Cast of elements. 00217 // All elements which simply accumulate attributes which are then used 00218 // by one of the above elements. 00219 else if (name == "MaterialFraction" || name == "ParE" || name == "ParS" 00220 || name == "RZPoint" || name == "PartSelector" 00221 || name == "Parameter" || name == "ZSection" 00222 || name == "Translation" 00223 || name == "rSolid" || name == "rMaterial" 00224 || name == "rParent" || name == "rChild" 00225 || name == "rRotation" || name == "rReflectionRotation" 00226 || name == "DDDefinition" ) 00227 { 00228 myret = new DDXMLElement; 00229 } 00230 00231 00232 // IF it is a new element return a default XMLElement which processes nothing. 00233 // Since there are elements in the XML which require no processing, they 00234 // can all use the same DDXMLElement which defaults to anything. A validated 00235 // XML document (i.e. validated with XML Schema) will work properly. 00236 // As of 8/16/2002: Elements like LogicalPartSection and any other *Section 00237 // XML elements of the DDLSchema are taken care of by this. 00238 else 00239 { 00240 myret = instance()->DDXMLElementRegistry::getElement("***"); 00241 DCOUT_V('P', "WARNING: The default (DDLElementRegistry) was used for " 00242 << name << " since there was no specific handler." << std::endl); 00243 } 00244 00245 // Actually register the thing 00246 instance()->registerElement(name, myret); 00247 } 00248 00249 return myret; 00250 }
DDLElementRegistry * DDLElementRegistry::instance | ( | ) | [static] |
This makes it a singleton.
Definition at line 82 of file DDLElementRegistry.cc.
References DDXMLElementRegistry::registerElement().
Referenced by getElement(), MapPair::operator()(), MapMakeName::operator()(), MapMakeDouble::operator()(), DDLRotationByAxis::processElement(), VectorMakeDouble::VectorMakeDouble(), and VectorMakeString::VectorMakeString().
00083 { 00084 static DDLElementRegistry reg; 00085 static bool isInit=false; 00086 if (!isInit) { 00087 isInit=true; 00088 instance()->registerElement("***", new DDXMLElement); 00089 } 00090 return ® 00091 /* 00092 if (instance_ == 0) 00093 { 00094 instance_ = new DDLElementRegistry; 00095 00096 DDXMLElement* defaultElement = new DDXMLElement; 00097 instance()->registerElement(defaultElement_, defaultElement); 00098 } 00099 return instance_; 00100 */ 00101 }