PageRenderTime 38ms CodeModel.GetById 13ms app.highlight 20ms RepoModel.GetById 2ms app.codeStats 0ms

/DetectorDescription/Parser/src/DDLAlgorithm.cc

https://github.com/aivanov-cern/cmssw
C++ | 87 lines | 57 code | 17 blank | 13 comment | 2 complexity | 1cc84709da46b52501a131e12ed6f3ec MD5 | raw file
 1/**************************************************************************
 2      DDLAlgorithm.cc  -  description
 3                             -------------------
 4    begin                : Saturday November 29, 2003
 5    email                : case@ucdhep.ucdavis.edu
 6 ***************************************************************************/
 7
 8/***************************************************************************
 9 *                                                                         *
10 *           DDDParser sub-component of DDD                                *
11 *                                                                         *
12 ***************************************************************************/
13
14#include "DetectorDescription/Parser/src/DDLAlgorithm.h"
15#include "DetectorDescription/Parser/src/DDLVector.h"
16#include "DetectorDescription/Parser/src/DDLMap.h"
17
18#include "DetectorDescription/Core/interface/DDName.h"
19#include "DetectorDescription/Base/interface/DDdebug.h"
20#include "DetectorDescription/Algorithm/interface/DDAlgorithmHandler.h"
21
22#include "DetectorDescription/ExprAlgo/interface/ClhepEvaluator.h"
23
24#include <sstream>
25
26DDLAlgorithm::DDLAlgorithm( DDLElementRegistry* myreg )
27  : DDXMLElement( myreg )
28{}
29
30DDLAlgorithm::~DDLAlgorithm( void )
31{}
32
33void
34DDLAlgorithm::preProcessElement( const std::string& name, const std::string& nmspace, DDCompactView& cpv )
35{
36  myRegistry_->getElement( "Vector" )->clear();
37}
38
39void
40DDLAlgorithm::processElement( const std::string& name, const std::string& nmspace, DDCompactView& cpv )
41{
42  DCOUT_V( 'P', "DDLAlgorithm::processElement started" );
43
44  DDXMLElement* myNumeric        = myRegistry_->getElement( "Numeric" );
45  DDXMLElement* myString         = myRegistry_->getElement( "String" );
46  DDXMLElement* myVector         = myRegistry_->getElement( "Vector" );
47  DDXMLElement* myMap            = myRegistry_->getElement( "Map" );
48  DDXMLElement* myrParent        = myRegistry_->getElement( "rParent" );
49
50  DDName algoName( getDDName( nmspace ));  
51  DDLogicalPart lp( DDName( myrParent->getDDName( nmspace )));
52  DDXMLAttribute atts;
53
54  // handle all Numeric elements in the Algorithm.
55  DDNumericArguments nArgs;
56  size_t i = 0;
57  for( ; i < myNumeric->size(); ++i )
58  {
59    atts = myNumeric->getAttributeSet( i );
60    nArgs[atts.find( "name" )->second] = myRegistry_->evaluator().eval( nmspace, atts.find( "value" )->second );
61  }
62
63  DDStringArguments sArgs;
64  for( i = 0; i < myString->size(); ++i )
65  {
66    atts = myString->getAttributeSet( i );
67    sArgs[atts.find( "name" )->second] = atts.find( "value" )->second;
68  }
69
70  DDAlgorithmHandler handler;
71  atts = getAttributeSet();
72  DDLVector* tv = dynamic_cast<DDLVector*>( myVector );
73  DDLMap* tm = dynamic_cast<DDLMap*>( myMap );
74  handler.initialize( algoName, lp, nArgs, tv->getMapOfVectors(), tm->getMapOfMaps(), sArgs, tv->getMapOfStrVectors());
75  handler.execute( cpv );
76
77  // clear used/referred to elements.
78  myString->clear();
79  myNumeric->clear();
80  myVector->clear();
81  myMap->clear();
82  myrParent->clear();
83  clear();
84
85  DCOUT_V( 'P', "DDLAlgorithm::processElement(...)" );
86}
87