Back to home page

Project CMSSW displayed by LXR

 
 

    


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

0001 #include "DetectorDescription/Parser/src/DDLAlgorithm.h"
0002 #include "DetectorDescription/Core/interface/DDAlgorithmHandler.h"
0003 #include "DetectorDescription/Core/interface/DDTypes.h"
0004 #include "DetectorDescription/Core/interface/DDLogicalPart.h"
0005 #include "DetectorDescription/Core/interface/DDName.h"
0006 #include "DetectorDescription/Core/interface/ClhepEvaluator.h"
0007 #include "DetectorDescription/Parser/interface/DDLElementRegistry.h"
0008 #include "DetectorDescription/Parser/src/DDLMap.h"
0009 #include "DetectorDescription/Parser/src/DDLVector.h"
0010 #include "DetectorDescription/Parser/src/DDXMLElement.h"
0011 
0012 #include <cstddef>
0013 #include <map>
0014 #include <utility>
0015 
0016 class DDCompactView;
0017 
0018 DDLAlgorithm::DDLAlgorithm(DDLElementRegistry* myreg) : DDXMLElement(myreg) {}
0019 
0020 void DDLAlgorithm::preProcessElement(const std::string& name, const std::string& nmspace, DDCompactView& cpv) {
0021   myRegistry_->getElement("Vector")->clear();
0022 }
0023 
0024 void DDLAlgorithm::processElement(const std::string& name, const std::string& nmspace, DDCompactView& cpv) {
0025   auto myNumeric = myRegistry_->getElement("Numeric");
0026   auto myString = myRegistry_->getElement("String");
0027   auto myVector = myRegistry_->getElement("Vector");
0028   auto myMap = myRegistry_->getElement("Map");
0029   auto myrParent = myRegistry_->getElement("rParent");
0030 
0031   DDName algoName(getDDName(nmspace));
0032   DDLogicalPart lp(DDName(myrParent->getDDName(nmspace)));
0033   DDXMLAttribute atts;
0034 
0035   // handle all Numeric elements in the Algorithm.
0036   DDNumericArguments nArgs;
0037   size_t i = 0;
0038   for (; i < myNumeric->size(); ++i) {
0039     atts = myNumeric->getAttributeSet(i);
0040     nArgs[atts.find("name")->second] = myRegistry_->evaluator().eval(nmspace, atts.find("value")->second);
0041   }
0042 
0043   DDStringArguments sArgs;
0044   for (i = 0; i < myString->size(); ++i) {
0045     atts = myString->getAttributeSet(i);
0046     sArgs[atts.find("name")->second] = atts.find("value")->second;
0047   }
0048 
0049   DDAlgorithmHandler handler;
0050   atts = getAttributeSet();
0051   handler.initialize(algoName,
0052                      lp,
0053                      nArgs,
0054                      static_cast<DDLVector*>(myVector.get())->getMapOfVectors(),
0055                      static_cast<DDLMap*>(myMap.get())->getMapOfMaps(),
0056                      sArgs,
0057                      static_cast<DDLVector*>(myVector.get())->getMapOfStrVectors());
0058   handler.execute(cpv);
0059 
0060   // clear used/referred to elements.
0061   myString->clear();
0062   myNumeric->clear();
0063   myVector->clear();
0064   myMap->clear();
0065   myrParent->clear();
0066   clear();
0067 }