From 378f5be56349bc74b750c8bc07ce9f22ad34f138 Mon Sep 17 00:00:00 2001 From: Ianna Osborne Date: Wed, 26 Apr 2017 11:15:37 +0200 Subject: [PATCH 1/2] Use shared pointers --- .../Parser/interface/DDLElementRegistry.h | 29 ++--- .../Parser/src/DDLAlgorithm.cc | 17 +-- .../Parser/src/DDLBooleanSolid.cc | 12 +-- .../Parser/src/DDLCompositeMaterial.cc | 4 +- .../Parser/src/DDLElementRegistry.cc | 100 +++++++----------- .../Parser/src/DDLLogicalPart.cc | 4 +- DetectorDescription/Parser/src/DDLMap.cc | 6 +- DetectorDescription/Parser/src/DDLMaterial.cc | 2 +- .../Parser/src/DDLPolyGenerator.cc | 4 +- DetectorDescription/Parser/src/DDLPosPart.cc | 14 +-- .../Parser/src/DDLReflectionSolid.cc | 2 +- .../Parser/src/DDLRotationByAxis.cc | 9 +- .../Parser/src/DDLRotationSequence.cc | 4 +- .../Parser/src/DDLSAX2FileHandler.cc | 6 +- DetectorDescription/Parser/src/DDLSolid.cc | 4 +- DetectorDescription/Parser/src/DDLSpecPar.cc | 10 +- DetectorDescription/Parser/src/DDLVector.cc | 25 ++--- 17 files changed, 105 insertions(+), 147 deletions(-) diff --git a/DetectorDescription/Parser/interface/DDLElementRegistry.h b/DetectorDescription/Parser/interface/DDLElementRegistry.h index b6094199b92ce..83610d802eeaf 100644 --- a/DetectorDescription/Parser/interface/DDLElementRegistry.h +++ b/DetectorDescription/Parser/interface/DDLElementRegistry.h @@ -1,28 +1,21 @@ -#ifndef DDL_ElementRegistry_H -#define DDL_ElementRegistry_H - -#include -#include +#ifndef DETECTOR_DESCRIPTION_PARSER_DDL_ELEMENT_REGISTRY_H +#define DETECTOR_DESCRIPTION_PARSER_DDL_ELEMENT_REGISTRY_H #include "DetectorDescription/Base/interface/Singleton.h" #include "DetectorDescription/Base/interface/Singleton.icc" - -class DDXMLElement; +#include "DetectorDescription/ExprAlgo/interface/ExprEvalSingleton.h" #include -#include "DetectorDescription/ExprAlgo/interface/ExprEvalSingleton.h" +#include +#include +#include + +class DDXMLElement; /// The main class for processing parsed elements. /** \class DDLElementRegistry * - * - * 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. @@ -33,7 +26,7 @@ class DDLElementRegistry { public: - typedef std::map RegistryMap; + typedef std::map > RegistryMap; DDLElementRegistry(); @@ -48,10 +41,8 @@ class DDLElementRegistry * return a pointer if already registered or NULL, no instantiating. * */ - DDXMLElement* getElement(const std::string& name); + std::shared_ptr getElement(const std::string& name); - /// Get the name given a pointer. This may not be needed... - const std::string& getElementName(DDXMLElement* theElement) const; ClhepEvaluator &evaluator() { return ExprEvalSingleton::instance(); } private: diff --git a/DetectorDescription/Parser/src/DDLAlgorithm.cc b/DetectorDescription/Parser/src/DDLAlgorithm.cc index 1337104448902..e582313224dd8 100644 --- a/DetectorDescription/Parser/src/DDLAlgorithm.cc +++ b/DetectorDescription/Parser/src/DDLAlgorithm.cc @@ -29,11 +29,11 @@ DDLAlgorithm::preProcessElement( const std::string& name, const std::string& nms void DDLAlgorithm::processElement( const std::string& name, const std::string& nmspace, DDCompactView& cpv ) { - DDXMLElement* myNumeric = myRegistry_->getElement( "Numeric" ); - DDXMLElement* myString = myRegistry_->getElement( "String" ); - DDXMLElement* myVector = myRegistry_->getElement( "Vector" ); - DDXMLElement* myMap = myRegistry_->getElement( "Map" ); - DDXMLElement* myrParent = myRegistry_->getElement( "rParent" ); + auto myNumeric = myRegistry_->getElement( "Numeric" ); + auto myString = myRegistry_->getElement( "String" ); + auto myVector = myRegistry_->getElement( "Vector" ); + auto myMap = myRegistry_->getElement( "Map" ); + auto myrParent = myRegistry_->getElement( "rParent" ); DDName algoName( getDDName( nmspace )); DDLogicalPart lp( DDName( myrParent->getDDName( nmspace ))); @@ -57,9 +57,10 @@ DDLAlgorithm::processElement( const std::string& name, const std::string& nmspac DDAlgorithmHandler handler; atts = getAttributeSet(); - DDLVector* tv = dynamic_cast( myVector ); - DDLMap* tm = dynamic_cast( myMap ); - handler.initialize( algoName, lp, nArgs, tv->getMapOfVectors(), tm->getMapOfMaps(), sArgs, tv->getMapOfStrVectors()); + handler.initialize( algoName, lp, nArgs, + static_cast( myVector.get())->getMapOfVectors(), + static_cast( myMap.get())->getMapOfMaps(), sArgs, + static_cast( myVector.get())->getMapOfStrVectors()); handler.execute( cpv ); // clear used/referred to elements. diff --git a/DetectorDescription/Parser/src/DDLBooleanSolid.cc b/DetectorDescription/Parser/src/DDLBooleanSolid.cc index 1f73f7af58c45..71323910e9a3c 100644 --- a/DetectorDescription/Parser/src/DDLBooleanSolid.cc +++ b/DetectorDescription/Parser/src/DDLBooleanSolid.cc @@ -32,9 +32,9 @@ DDLBooleanSolid::processElement( const std::string& name, const std::string& nms // - DDXMLElement* myrSolid = myRegistry_->getElement( "rSolid" ); // get rSolid children - DDXMLElement* myTranslation = myRegistry_->getElement( "Translation" ); // get Translation child - DDXMLElement* myrRotation = myRegistry_->getElement( "rRotation" ); // get rRotation child + auto myrSolid = myRegistry_->getElement( "rSolid" ); // get rSolid children + auto myTranslation = myRegistry_->getElement( "Translation" ); // get Translation child + auto myrRotation = myRegistry_->getElement( "rRotation" ); // get rRotation child ClhepEvaluator & ev = myRegistry_->evaluator(); DDXMLAttribute atts = getAttributeSet(); @@ -133,9 +133,9 @@ DDLBooleanSolid::dumpBooleanSolid( const std::string& name, const std::string& n if (atts.find("secondSolid") != atts.end()) s+= " secondSolid=\"" + atts.find("secondSolid")->second + "\""; s += ">\n"; - DDXMLElement* myrSolid = myRegistry_->getElement("rSolid"); // get rSolid children - DDXMLElement* myTranslation = myRegistry_->getElement("Translation"); // get Translation child - DDXMLElement* myrRotation = myRegistry_->getElement("rRotation"); // get rRotation child + auto myrSolid = myRegistry_->getElement("rSolid"); // get rSolid children + auto myTranslation = myRegistry_->getElement("Translation"); // get Translation child + auto myrRotation = myRegistry_->getElement("rRotation"); // get rRotation child if (myrSolid->size() > 0) { for (size_t i = 0; i < myrSolid->size(); ++i) diff --git a/DetectorDescription/Parser/src/DDLCompositeMaterial.cc b/DetectorDescription/Parser/src/DDLCompositeMaterial.cc index 592392ce0a8a6..d1635164692dd 100644 --- a/DetectorDescription/Parser/src/DDLCompositeMaterial.cc +++ b/DetectorDescription/Parser/src/DDLCompositeMaterial.cc @@ -39,8 +39,8 @@ DDLCompositeMaterial::processElement( const std::string& name, const std::string mat = DDMaterial( ddn, ev.eval( nmspace, atts.find( "density" )->second )); // Get references to relevant DDL elements that are needed. - DDXMLElement* myMF = myRegistry_->getElement( "MaterialFraction" ); - DDXMLElement* myrMaterial = myRegistry_->getElement( "rMaterial" ); + auto myMF = myRegistry_->getElement( "MaterialFraction" ); + auto myrMaterial = myRegistry_->getElement( "rMaterial" ); // Get the names from those elements and also the namespace for the reference element. // The parent element CompositeMaterial MUST be in the same namespace as this fraction. diff --git a/DetectorDescription/Parser/src/DDLElementRegistry.cc b/DetectorDescription/Parser/src/DDLElementRegistry.cc index bba11c17aec3f..9114fa5f9b5fc 100644 --- a/DetectorDescription/Parser/src/DDLElementRegistry.cc +++ b/DetectorDescription/Parser/src/DDLElementRegistry.cc @@ -44,150 +44,136 @@ DDLElementRegistry::DDLElementRegistry( void ) DDLElementRegistry::~DDLElementRegistry( void ) { - // Complicated cleanup. I keep track of DDXMLElements that have - // already been deleted using this vector. Then delete them one-by-one. - std::vector toDelete; - for( RegistryMap::const_iterator it = registry_.begin(), end = registry_.end(); it != end; ++it ) - { - std::vector::const_iterator deleteIt = std::find( toDelete.begin(), toDelete.end(), it->second ); - if( deleteIt == toDelete.end()) - { - toDelete.push_back( it->second ); - delete it->second; - } - } + registry_.clear(); } -// ------------------------------------------------------------------------- -// Implementation -// ------------------------------------------------------------------------- -DDXMLElement* +std::shared_ptr DDLElementRegistry::getElement( const std::string& name ) { - RegistryMap::iterator it = registry_.find(name); - DDXMLElement* myret = NULL; + RegistryMap::iterator it = registry_.find( name ); + std::shared_ptr myret( nullptr ); if( it != registry_.end()) { - myret = it->second; + return it->second; } else { // Make the Solid handlers and register them. if (name == "Box") { - myret = new DDLBox(this); + myret = std::make_shared(this); } else if (name == "Cone") { - myret = new DDLCone(this); + myret = std::make_shared(this); } else if (name == "Polyhedra" || name == "Polycone") { - myret = new DDLPolyGenerator(this); + myret = std::make_shared(this); } else if (name == "Trapezoid" || name == "Trd1") { - myret = new DDLTrapezoid(this); + myret = std::make_shared(this); } else if (name == "PseudoTrap") { - myret = new DDLPseudoTrap(this); + myret = std::make_shared(this); } else if (name == "Tubs" || name == "CutTubs" || name == "Tube" || name == "TruncTubs") { - myret = new DDLTubs(this); + myret = std::make_shared(this); } else if (name == "Torus") { - myret = new DDLTorus(this); + myret = std::make_shared(this); } else if (name == "ReflectionSolid") { - myret = new DDLReflectionSolid(this); + myret = std::make_shared(this); } else if (name == "UnionSolid" || name == "SubtractionSolid" || name == "IntersectionSolid") { - myret = new DDLBooleanSolid(this); + myret = std::make_shared(this); } else if (name == "ShapelessSolid") { - myret = new DDLShapelessSolid(this); + myret = std::make_shared(this); } else if (name == "Sphere") { - myret = new DDLSphere(this); + myret = std::make_shared(this); } else if (name == "Orb") { - myret = new DDLOrb(this); + myret = std::make_shared(this); } else if (name == "EllipticalTube") { - myret = new DDLEllipticalTube(this); + myret = std::make_shared(this); } else if (name == "Ellipsoid") { - myret = new DDLEllipsoid(this); + myret = std::make_shared(this); } else if (name == "Parallelepiped") { - myret = new DDLParallelepiped(this); + myret = std::make_shared(this); } // LogicalParts, Positioners, Materials, Rotations, Reflections // and Specific (Specified?) Parameters else if (name == "PosPart") { - myret = new DDLPosPart(this); + myret = std::make_shared(this); } else if (name == "CompositeMaterial") { - myret = new DDLCompositeMaterial(this); + myret = std::make_shared(this); } else if (name == "ElementaryMaterial") { - myret = new DDLElementaryMaterial(this); + myret = std::make_shared(this); } else if (name == "LogicalPart") { - myret = new DDLLogicalPart(this); + myret = std::make_shared(this); } else if (name == "ReflectionRotation" || name == "Rotation" ) { - myret = new DDLRotationAndReflection(this); + myret = std::make_shared(this); } else if (name == "SpecPar") { - myret = new DDLSpecPar(this); + myret = std::make_shared(this); } else if (name == "RotationSequence") { - myret = new DDLRotationSequence(this); + myret = std::make_shared(this); } else if (name == "RotationByAxis") { - myret = new DDLRotationByAxis(this); + myret = std::make_shared(this); } // Special, need them around. else if (name == "SpecParSection") { - myret = new DDXMLElement(this, true); + myret = std::make_shared(this, true); } else if (name == "Vector") { - myret = new DDLVector(this); + myret = std::make_shared(this); } else if (name == "Map") { - myret = new DDLMap(this); + myret = std::make_shared(this); } else if (name == "String") { - myret = new DDLString(this); + myret = std::make_shared(this); } else if (name == "Numeric") { - myret = new DDLNumeric(this); + myret = std::make_shared(this); } else if (name == "Algorithm") { - myret = new DDLAlgorithm(this); + myret = std::make_shared(this); } else if (name == "Division") { - myret = new DDLDivision(this); + myret = std::make_shared(this); } // Supporting Cast of elements. @@ -202,7 +188,7 @@ DDLElementRegistry::getElement( const std::string& name ) || name == "rRotation" || name == "rReflectionRotation" || name == "DDDefinition" ) { - myret = new DDXMLElement(this); + myret = std::make_shared(this); } // IF it is a new element return a default XMLElement which processes nothing. @@ -213,23 +199,13 @@ DDLElementRegistry::getElement( const std::string& name ) // XML elements of the DDLSchema are taken care of by this. else { - myret = new DDXMLElement(this); + myret = std::make_shared(this); } // Actually register the thing - registry_[name] = myret; + registry_[name]= myret; } return myret; } -const std::string& -DDLElementRegistry::getElementName( DDXMLElement* theElement ) const -{ - for( RegistryMap::const_iterator it = registry_.begin(), end = registry_.end(); it != end; ++it ) - if( it->second == theElement ) - return it->first; - return registry_.find( "***" )->first; -} - template class DDI::Singleton; - diff --git a/DetectorDescription/Parser/src/DDLLogicalPart.cc b/DetectorDescription/Parser/src/DDLLogicalPart.cc index c2585b5feb118..db65f90ce8032 100644 --- a/DetectorDescription/Parser/src/DDLLogicalPart.cc +++ b/DetectorDescription/Parser/src/DDLLogicalPart.cc @@ -46,8 +46,8 @@ void DDLLogicalPart::processElement( const std::string& name, const std::string& nmspace, DDCompactView& cpv ) { // rMaterial and rSolid - DDXMLElement* myrMaterial = myRegistry_->getElement("rMaterial"); // get Material reference child - DDXMLElement* myrSolid = myRegistry_->getElement("rSolid"); // get Solid reference child + auto myrMaterial = myRegistry_->getElement("rMaterial"); // get Material reference child + auto myrSolid = myRegistry_->getElement("rSolid"); // get Solid reference child DDXMLAttribute atts = getAttributeSet(); diff --git a/DetectorDescription/Parser/src/DDLMap.cc b/DetectorDescription/Parser/src/DDLMap.cc index eb0d53ffc0e60..8d2ef8f92d8fe 100644 --- a/DetectorDescription/Parser/src/DDLMap.cc +++ b/DetectorDescription/Parser/src/DDLMap.cc @@ -46,21 +46,21 @@ template struct Mapper::definition void MapPair::operator() (char const* str, char const* end) const { - DDLMap* myDDLMap = dynamic_cast < DDLMap* > (DDLGlobalRegistry::instance().getElement("Map")); + std::shared_ptr myDDLMap = std::static_pointer_cast(DDLGlobalRegistry::instance().getElement("Map")); myDDLMap->do_pair(str, end); } void MapMakeName::operator() (char const* str, char const* end) const { - DDLMap* myDDLMap = dynamic_cast < DDLMap* > (DDLGlobalRegistry::instance().getElement("Map")); + std::shared_ptr myDDLMap = std::static_pointer_cast(DDLGlobalRegistry::instance().getElement("Map")); myDDLMap->do_makeName(str, end); } void MapMakeDouble::operator() (char const* str, char const* end)const { - DDLMap* myDDLMap = dynamic_cast < DDLMap* > (DDLGlobalRegistry::instance().getElement("Map")); + std::shared_ptr myDDLMap = std::static_pointer_cast(DDLGlobalRegistry::instance().getElement("Map")); myDDLMap->do_makeDouble(str, end); } diff --git a/DetectorDescription/Parser/src/DDLMaterial.cc b/DetectorDescription/Parser/src/DDLMaterial.cc index 554c87a728120..3262ce6d43741 100644 --- a/DetectorDescription/Parser/src/DDLMaterial.cc +++ b/DetectorDescription/Parser/src/DDLMaterial.cc @@ -22,7 +22,7 @@ DDLMaterial::setReference( const std::string& nmspace, DDCompactView& cpv ) // Attempt to make sure Material elements can be in LogicalPart elements. if (myRegistry_->getElement("LogicalPart")->size() > 0) { - DDXMLElement* refmat = myRegistry_->getElement("rMaterial"); + auto refmat = myRegistry_->getElement("rMaterial"); std::vector names; std::vector values; names.push_back("name"); diff --git a/DetectorDescription/Parser/src/DDLPolyGenerator.cc b/DetectorDescription/Parser/src/DDLPolyGenerator.cc index 5640eb83ebbff..c6bc5bd82c99e 100644 --- a/DetectorDescription/Parser/src/DDLPolyGenerator.cc +++ b/DetectorDescription/Parser/src/DDLPolyGenerator.cc @@ -30,8 +30,8 @@ DDLPolyGenerator::preProcessElement( const std::string& name, const std::string& void DDLPolyGenerator::processElement( const std::string& name, const std::string& nmspace, DDCompactView& cpv ) { - DDXMLElement* myRZPoints = myRegistry_->getElement("RZPoint"); - DDXMLElement* myZSection = myRegistry_->getElement("ZSection"); + auto myRZPoints = myRegistry_->getElement("RZPoint"); + auto myZSection = myRegistry_->getElement("ZSection"); ClhepEvaluator & ev = myRegistry_->evaluator(); DDXMLAttribute atts; diff --git a/DetectorDescription/Parser/src/DDLPosPart.cc b/DetectorDescription/Parser/src/DDLPosPart.cc index 1843686052375..b6d9d5e263c1b 100644 --- a/DetectorDescription/Parser/src/DDLPosPart.cc +++ b/DetectorDescription/Parser/src/DDLPosPart.cc @@ -38,13 +38,13 @@ void DDLPosPart::processElement( const std::string& name, const std::string& nmspace, DDCompactView& cpv ) { // get all internal elements. - DDXMLElement* myParent = myRegistry_->getElement("rParent"); - DDXMLElement* myChild = myRegistry_->getElement("rChild"); - DDXMLElement* myTranslation= myRegistry_->getElement("Translation"); - DDXMLElement* myDDLRotation= myRegistry_->getElement("Rotation"); - DDXMLElement* myrRotation = myRegistry_->getElement("rRotation"); - DDXMLElement* myDDLRefl = myRegistry_->getElement("ReflectionRotation"); - DDXMLElement* myrRefl = myRegistry_->getElement("rReflectionRotation"); + auto myParent = myRegistry_->getElement("rParent"); + auto myChild = myRegistry_->getElement("rChild"); + auto myTranslation= myRegistry_->getElement("Translation"); + auto myDDLRotation= myRegistry_->getElement("Rotation"); + auto myrRotation = myRegistry_->getElement("rRotation"); + auto myDDLRefl = myRegistry_->getElement("ReflectionRotation"); + auto myrRefl = myRegistry_->getElement("rReflectionRotation"); // FIXME!!! add in the new RotationByAxis element... // At this time, PosPart is becoming the most complex of the elements. diff --git a/DetectorDescription/Parser/src/DDLReflectionSolid.cc b/DetectorDescription/Parser/src/DDLReflectionSolid.cc index 7d7f51b93e6db..95c6b8613c469 100644 --- a/DetectorDescription/Parser/src/DDLReflectionSolid.cc +++ b/DetectorDescription/Parser/src/DDLReflectionSolid.cc @@ -26,7 +26,7 @@ void DDLReflectionSolid::processElement( const std::string& name, const std::string& nmspace, DDCompactView& cpv ) { // get solid reference: - DDXMLElement* myrSolid = myRegistry_->getElement("rSolid"); + auto myrSolid = myRegistry_->getElement("rSolid"); if (myrSolid->size() != 1) { diff --git a/DetectorDescription/Parser/src/DDLRotationByAxis.cc b/DetectorDescription/Parser/src/DDLRotationByAxis.cc index 83776c65aed77..2528166575ae6 100644 --- a/DetectorDescription/Parser/src/DDLRotationByAxis.cc +++ b/DetectorDescription/Parser/src/DDLRotationByAxis.cc @@ -42,20 +42,15 @@ DDLRotationByAxis::processElement( const std::string& name, const std::string& n DDRotationMatrix* ddr = new DDRotationMatrix(R); if (atts.find("name") == atts.end()) { - //how do we make up a ddname! damn_it! - // DDXMLElement * myRealParent = DDLElementRegistry::instance()->getElement(parent()); - DDXMLElement * myRealParent = myRegistry_->getElement(parent()); + auto myRealParent = myRegistry_->getElement(parent()); DDName pName = myRealParent->getDDName(nmspace); std::string tn = pName.name() + std::string("Rotation"); std::vector names; names.push_back("name"); - //no need, used already names.push_back("axis"); - //no need, used already names.push_back("angle"); std::vector values; values.push_back(tn); - //no need, used already values.push_back(atts.find("axis")->second); - //no need, used already values.push_back(atts.find("angle")->second); + clear(); loadAttributes(name, names, values, nmspace, cpv); } diff --git a/DetectorDescription/Parser/src/DDLRotationSequence.cc b/DetectorDescription/Parser/src/DDLRotationSequence.cc index 25567554faa44..595b5750cfc17 100644 --- a/DetectorDescription/Parser/src/DDLRotationSequence.cc +++ b/DetectorDescription/Parser/src/DDLRotationSequence.cc @@ -29,8 +29,7 @@ DDLRotationSequence::processElement( const std::string& name, const std::string& /** Get the name, axis and angle of each Rotate child and make this the rotation. */ - DDLRotationByAxis* myRotations = - dynamic_cast (myRegistry_->getElement("RotationByAxis")); + std::shared_ptr myRotations = std::static_pointer_cast(myRegistry_->getElement("RotationByAxis")); DDXMLAttribute atts; DDRotationMatrix R; @@ -46,3 +45,4 @@ DDLRotationSequence::processElement( const std::string& name, const std::string& myRotations->clear(); clear(); } + diff --git a/DetectorDescription/Parser/src/DDLSAX2FileHandler.cc b/DetectorDescription/Parser/src/DDLSAX2FileHandler.cc index 96c85896d079c..19279b5cf5530 100644 --- a/DetectorDescription/Parser/src/DDLSAX2FileHandler.cc +++ b/DetectorDescription/Parser/src/DDLSAX2FileHandler.cc @@ -46,7 +46,7 @@ DDLSAX2FileHandler::startElement( const XMLCh* const uri, names_.push_back(namesMap_.size() - 1); } - DDXMLElement* myElement = DDLGlobalRegistry::instance().getElement(myElementName); + auto myElement = DDLGlobalRegistry::instance().getElement(myElementName); unsigned int numAtts = attrs.getLength(); std::vector attrNames, attrValues; @@ -70,7 +70,7 @@ DDLSAX2FileHandler::endElement( const XMLCh* const uri, std::string ts(cStr(qname).ptr()); const std::string& myElementName = self(); - DDXMLElement* myElement = DDLGlobalRegistry::instance().getElement(myElementName); + auto myElement = DDLGlobalRegistry::instance().getElement(myElementName); std::string nmspace = nmspace_; // The need for processElement to have the nmspace so that it can @@ -98,7 +98,7 @@ void DDLSAX2FileHandler::characters( const XMLCh* const chars, const XMLSize_t length ) { - DDXMLElement* myElement = DDLGlobalRegistry::instance().getElement(self()); + auto myElement = DDLGlobalRegistry::instance().getElement(self()); std::string inString = ""; for (XMLSize_t i = 0; i < length; ++i) { diff --git a/DetectorDescription/Parser/src/DDLSolid.cc b/DetectorDescription/Parser/src/DDLSolid.cc index c9dd693b672d4..fedbca3a1300f 100644 --- a/DetectorDescription/Parser/src/DDLSolid.cc +++ b/DetectorDescription/Parser/src/DDLSolid.cc @@ -17,13 +17,13 @@ void DDLSolid::setReference( const std::string& nmspace, DDCompactView& cpv ) { // in case it was a BooleanSolid or a ReflectionSolid, clear rSolid. - DDXMLElement* myrSolid = myRegistry_->getElement("rSolid"); + auto myrSolid = myRegistry_->getElement("rSolid"); myrSolid->clear(); // Make sure Solid elements are in LogicalPart elements. if (parent() == "LogicalPart") { - DDXMLElement* refsol = myRegistry_->getElement("rSolid"); + auto refsol = myRegistry_->getElement("rSolid"); std::vector names; std::vector values; names.push_back("name"); diff --git a/DetectorDescription/Parser/src/DDLSpecPar.cc b/DetectorDescription/Parser/src/DDLSpecPar.cc index e738bc7231fc1..2851d67502d93 100644 --- a/DetectorDescription/Parser/src/DDLSpecPar.cc +++ b/DetectorDescription/Parser/src/DDLSpecPar.cc @@ -35,11 +35,11 @@ DDLSpecPar::processElement( const std::string& name, const std::string& nmspace, // for each of the above, use the name of the SpecPar, since DDL does not // provide a name for a PartSelector. - DDXMLElement* myParameter = myRegistry_->getElement("Parameter"); - DDXMLElement* myNumeric = myRegistry_->getElement("Numeric"); - DDXMLElement* myString = myRegistry_->getElement("String"); - DDXMLElement* myPartSelector = myRegistry_->getElement("PartSelector"); - DDXMLElement* mySpecParSection = myRegistry_->getElement("SpecParSection"); + auto myParameter = myRegistry_->getElement("Parameter"); + auto myNumeric = myRegistry_->getElement("Numeric"); + auto myString = myRegistry_->getElement("String"); + auto myPartSelector = myRegistry_->getElement("PartSelector"); + auto mySpecParSection = myRegistry_->getElement("SpecParSection"); // Because of namespace magic "!" means namespaces should be provided // in the names of the XML elements for the DDD. So if this is diff --git a/DetectorDescription/Parser/src/DDLVector.cc b/DetectorDescription/Parser/src/DDLVector.cc index 053a72e6f8615..b913c91285b23 100644 --- a/DetectorDescription/Parser/src/DDLVector.cc +++ b/DetectorDescription/Parser/src/DDLVector.cc @@ -2,6 +2,7 @@ #include #include +#include #include #include "DetectorDescription/Core/interface/DDStrVector.h" @@ -26,10 +27,10 @@ class VectorMakeDouble } VectorMakeDouble() { - ddlVector_ = dynamic_cast < DDLVector* > (DDLGlobalRegistry::instance().getElement("Vector")); + ddlVector_ = std::static_pointer_cast(DDLGlobalRegistry::instance().getElement("Vector")); } private: - DDLVector * ddlVector_; + std::shared_ptr ddlVector_; }; class VectorMakeString @@ -41,10 +42,10 @@ class VectorMakeString } VectorMakeString() { - ddlVector_ = dynamic_cast < DDLVector* > (DDLGlobalRegistry::instance().getElement("Vector")); + ddlVector_ = std::static_pointer_cast(DDLGlobalRegistry::instance().getElement("Vector")); } private: - DDLVector * ddlVector_; + std::shared_ptr ddlVector_; }; bool @@ -92,17 +93,17 @@ DDLVector::processElement( const std::string& name, const std::string& nmspace, && atts.find("type")->second == "string") ? true : false); std::string tTextToParse = getText(); - // cout << "tTextToParse is |"<< tTextToParse << "|" << endl; + if (tTextToParse.size() == 0) { errorOut(" EMPTY STRING "); } - if (isNumVec) {//(atts.find("type") == atts.end() || atts.find("type")->second == "numeric") { + if (isNumVec) { if (!parse_numbers(tTextToParse.c_str())) { errorOut(tTextToParse.c_str()); } } - else if (isStringVec) { //(atts.find("type")->second == "string") { + else if (isStringVec) { if (!parse_strings(tTextToParse.c_str())) { errorOut(tTextToParse.c_str()); } @@ -111,19 +112,13 @@ DDLVector::processElement( const std::string& name, const std::string& nmspace, errorOut("Unexpected std::vector type. Only \"numeric\" and \"string\" are allowed."); } - if (parent() == "Algorithm" || parent() == "SpecPar") { - if (isNumVec) { //(atts.find("type") != atts.end() || atts.find("type")->second == "numeric") { - // std::cout << "adding to pVecMap name= " << atts.find("name")->second << std::endl; - // for (std::vector::const_iterator it = pVector.begin(); it != pVector.end(); ++it) - // std::cout << *it << "\t" << std::endl; + if (isNumVec) { pVecMap[atts.find("name")->second] = pVector; - // std::cout << "size: " << pVecMap.size() << std::endl; } - else if (isStringVec) { //(atts.find("type")->second == "string") { + else if (isStringVec) { pStrVecMap[atts.find("name")->second] = pStrVector; - // cout << "it is a string, name is: " << atts.find("name")->second << endl; } size_t expNEntries = 0; if (atts.find("nEntries") != atts.end()) { From 542f70802e0ec86b755f2e21708be612d901ce99 Mon Sep 17 00:00:00 2001 From: Ianna Osborne Date: Wed, 26 Apr 2017 11:20:02 +0200 Subject: [PATCH 2/2] Correct space --- DetectorDescription/Parser/src/DDLElementRegistry.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/DetectorDescription/Parser/src/DDLElementRegistry.cc b/DetectorDescription/Parser/src/DDLElementRegistry.cc index 9114fa5f9b5fc..d18925c0c9794 100644 --- a/DetectorDescription/Parser/src/DDLElementRegistry.cc +++ b/DetectorDescription/Parser/src/DDLElementRegistry.cc @@ -203,7 +203,7 @@ DDLElementRegistry::getElement( const std::string& name ) } // Actually register the thing - registry_[name]= myret; + registry_[name] = myret; } return myret; }