CMS 3D CMS Logo

/afs/cern.ch/work/a/aaltunda/public/www/CMSSW_6_2_5/src/DetectorDescription/Parser/src/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 #include "DetectorDescription/Parser/src/DDLAlgorithm.h"
00015 #include "DetectorDescription/Parser/src/DDLVector.h"
00016 #include "DetectorDescription/Parser/src/DDLMap.h"
00017 
00018 #include "DetectorDescription/Core/interface/DDName.h"
00019 #include "DetectorDescription/Base/interface/DDdebug.h"
00020 #include "DetectorDescription/Algorithm/interface/DDAlgorithmHandler.h"
00021 
00022 #include "DetectorDescription/ExprAlgo/interface/ExprEvalSingleton.h"
00023 
00024 #include <sstream>
00025 
00026 DDLAlgorithm::DDLAlgorithm( DDLElementRegistry* myreg )
00027   : DDXMLElement( myreg )
00028 {}
00029 
00030 DDLAlgorithm::~DDLAlgorithm( void )
00031 {}
00032 
00033 void
00034 DDLAlgorithm::preProcessElement( const std::string& name, const std::string& nmspace, DDCompactView& cpv )
00035 {
00036   myRegistry_->getElement( "Vector" )->clear();
00037 }
00038 
00039 void
00040 DDLAlgorithm::processElement( const std::string& name, const std::string& nmspace, DDCompactView& cpv )
00041 {
00042   DCOUT_V( 'P', "DDLAlgorithm::processElement started" );
00043 
00044   DDXMLElement* myNumeric        = myRegistry_->getElement( "Numeric" );
00045   DDXMLElement* myString         = myRegistry_->getElement( "String" );
00046   DDXMLElement* myVector         = myRegistry_->getElement( "Vector" );
00047   DDXMLElement* myMap            = myRegistry_->getElement( "Map" );
00048   DDXMLElement* myrParent        = myRegistry_->getElement( "rParent" );
00049 
00050   DDName algoName( getDDName( nmspace ));  
00051   DDLogicalPart lp( DDName( myrParent->getDDName( nmspace )));
00052   DDXMLAttribute atts;
00053 
00054   // handle all Numeric elements in the Algorithm.
00055   DDNumericArguments nArgs;
00056   size_t i = 0;
00057   for( ; i < myNumeric->size(); ++i )
00058   {
00059     atts = myNumeric->getAttributeSet( i );
00060     nArgs[atts.find( "name" )->second] = ExprEvalSingleton::instance().eval( nmspace, atts.find( "value" )->second );
00061   }
00062 
00063   DDStringArguments sArgs;
00064   for( i = 0; i < myString->size(); ++i )
00065   {
00066     atts = myString->getAttributeSet( i );
00067     sArgs[atts.find( "name" )->second] = atts.find( "value" )->second;
00068   }
00069 
00070   DDAlgorithmHandler handler;
00071   atts = getAttributeSet();
00072   DDLVector* tv = dynamic_cast<DDLVector*>( myVector );
00073   DDLMap* tm = dynamic_cast<DDLMap*>( myMap );
00074   handler.initialize( algoName, lp, nArgs, tv->getMapOfVectors(), tm->getMapOfMaps(), sArgs, tv->getMapOfStrVectors());
00075   handler.execute( cpv );
00076 
00077   // clear used/referred to elements.
00078   myString->clear();
00079   myNumeric->clear();
00080   myVector->clear();
00081   myMap->clear();
00082   myrParent->clear();
00083   clear();
00084 
00085   DCOUT_V( 'P', "DDLAlgorithm::processElement(...)" );
00086 }
00087