CMS 3D CMS Logo

DDLAlgorithm.cc

Go to the documentation of this file.
00001 /***************************************************************************
00002                           DDLAlgorithm.cc  -  description
00003                              -------------------
00004     begin                : Saturday November 29, 2003
00005     email                : case@ucdhep.ucdavis.edu
00006  ***************************************************************************/
00007 
00008 /***************************************************************************
00009  *                                                                         *
00010  *           DDDParser sub-component of DDD                                *
00011  *                                                                         *
00012  ***************************************************************************/
00013 
00014 
00015 
00016 // Parser parts
00017 #include "DDLAlgorithm.h"
00018 #include "DDLVector.h"
00019 #include "DDLMap.h"
00020 #include "DDLElementRegistry.h"
00021 #include "DDXMLElement.h"
00022 
00023 // DDCore dependencies
00024 #include "DetectorDescription/Core/interface/DDName.h"
00025 #include "DetectorDescription/Core/interface/DDSolid.h"
00026 #include "DetectorDescription/Base/interface/DDdebug.h"
00027 #include "DetectorDescription/Core/interface/DDNumeric.h"
00028 #include "DetectorDescription/Core/interface/DDString.h"
00029 #include "DetectorDescription/Core/interface/DDVector.h"
00030 #include "DetectorDescription/Core/interface/DDMap.h"
00031 #include "DetectorDescription/Algorithm/interface/DDAlgorithm.h"
00032 #include "DetectorDescription/Base/interface/DDException.h"
00033 
00034 #include "DetectorDescription/Algorithm/interface/DDAlgorithmHandler.h"
00035 
00036 // CLHEP dependencies
00037 #include "CLHEP/Units/SystemOfUnits.h"
00038 #include "DetectorDescription/ExprAlgo/interface/ExprEvalSingleton.h"
00039 
00040 #include <string>
00041 #include <sstream>
00042 
00043 DDLAlgorithm::DDLAlgorithm()
00044 {
00045 }
00046 
00047 DDLAlgorithm::~DDLAlgorithm()
00048 {
00049 }
00050 
00051 void DDLAlgorithm::preProcessElement (const std::string& name, const std::string& nmspace)
00052 {
00053   DDLElementRegistry::getElement("Vector")->clear();
00054 }
00055 
00056 void DDLAlgorithm::processElement (const std::string& name, const std::string& nmspace)
00057 {
00058   DCOUT_V('P',"DDLAlgorithm::processElement started");
00059 
00060   DDXMLElement* myNumeric        = DDLElementRegistry::getElement("Numeric");
00061   DDXMLElement* myString         = DDLElementRegistry::getElement("String");
00062   DDXMLElement* myVector         = DDLElementRegistry::getElement("Vector");
00063   DDXMLElement* myMap            = DDLElementRegistry::getElement("Map");
00064   DDXMLElement* myrParent        = DDLElementRegistry::getElement("rParent");
00065 
00066   DDName algoName(getDDName(nmspace));  
00067   DDLogicalPart lp(DDName(myrParent->getDDName(nmspace)));
00068   DDXMLAttribute atts;
00069 
00070   // handle all Numeric elements in the Algorithm.
00071   DDNumericArguments nArgs;
00072   size_t i = 0;
00073   for (; i < myNumeric->size(); ++i)
00074     {
00075       atts = myNumeric->getAttributeSet(i);
00076       nArgs[atts.find("name")->second] = ExprEvalSingleton::instance().eval(nmspace, atts.find("value")->second);
00077     }
00078 
00079   DDStringArguments sArgs;
00080   for (i = 0; i < myString->size(); ++i)
00081     {
00082       atts = myString->getAttributeSet(i);
00083       sArgs[atts.find("name")->second] = atts.find("value")->second;
00084     }
00085 
00086   DDAlgorithmHandler handler;
00087   atts = getAttributeSet();
00088   DDLVector* tv= dynamic_cast<DDLVector*> (myVector);
00089   DDLMap* tm= dynamic_cast<DDLMap*> (myMap);
00090   handler.initialize( algoName, lp, nArgs, tv->getMapOfVectors(), tm->getMapOfMaps(), sArgs, tv->getMapOfStrVectors() );
00091   handler.execute();
00092 
00093   // clear used/referred to elements.
00094   myString->clear();
00095   myNumeric->clear();
00096   myVector->clear();
00097   myMap->clear();
00098   myrParent->clear();
00099   clear();
00100 
00101   DCOUT_V('P',"DDLAlgorithm::processElement(...)");
00102 }
00103 

Generated on Tue Jun 9 17:32:23 2009 for CMSSW by  doxygen 1.5.4