/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. * DDDParser sub-component of DDD *
  10. * *
  11. ***************************************************************************/
  12. #include "DetectorDescription/Parser/src/DDLAlgorithm.h"
  13. #include "DetectorDescription/Parser/src/DDLVector.h"
  14. #include "DetectorDescription/Parser/src/DDLMap.h"
  15. #include "DetectorDescription/Core/interface/DDName.h"
  16. #include "DetectorDescription/Base/interface/DDdebug.h"
  17. #include "DetectorDescription/Algorithm/interface/DDAlgorithmHandler.h"
  18. #include "DetectorDescription/ExprAlgo/interface/ClhepEvaluator.h"
  19. #include <sstream>
  20. DDLAlgorithm::DDLAlgorithm( DDLElementRegistry* myreg )
  21. : DDXMLElement( myreg )
  22. {}
  23. DDLAlgorithm::~DDLAlgorithm( void )
  24. {}
  25. void
  26. DDLAlgorithm::preProcessElement( const std::string& name, const std::string& nmspace, DDCompactView& cpv )
  27. {
  28. myRegistry_->getElement( "Vector" )->clear();
  29. }
  30. void
  31. DDLAlgorithm::processElement( const std::string& name, const std::string& nmspace, DDCompactView& cpv )
  32. {
  33. DCOUT_V( 'P', "DDLAlgorithm::processElement started" );
  34. DDXMLElement* myNumeric = myRegistry_->getElement( "Numeric" );
  35. DDXMLElement* myString = myRegistry_->getElement( "String" );
  36. DDXMLElement* myVector = myRegistry_->getElement( "Vector" );
  37. DDXMLElement* myMap = myRegistry_->getElement( "Map" );
  38. DDXMLElement* myrParent = myRegistry_->getElement( "rParent" );
  39. DDName algoName( getDDName( nmspace ));
  40. DDLogicalPart lp( DDName( myrParent->getDDName( nmspace )));
  41. DDXMLAttribute atts;
  42. // handle all Numeric elements in the Algorithm.
  43. DDNumericArguments nArgs;
  44. size_t i = 0;
  45. for( ; i < myNumeric->size(); ++i )
  46. {
  47. atts = myNumeric->getAttributeSet( i );
  48. nArgs[atts.find( "name" )->second] = myRegistry_->evaluator().eval( nmspace, atts.find( "value" )->second );
  49. }
  50. DDStringArguments sArgs;
  51. for( i = 0; i < myString->size(); ++i )
  52. {
  53. atts = myString->getAttributeSet( i );
  54. sArgs[atts.find( "name" )->second] = atts.find( "value" )->second;
  55. }
  56. DDAlgorithmHandler handler;
  57. atts = getAttributeSet();
  58. DDLVector* tv = dynamic_cast<DDLVector*>( myVector );
  59. DDLMap* tm = dynamic_cast<DDLMap*>( myMap );
  60. handler.initialize( algoName, lp, nArgs, tv->getMapOfVectors(), tm->getMapOfMaps(), sArgs, tv->getMapOfStrVectors());
  61. handler.execute( cpv );
  62. // clear used/referred to elements.
  63. myString->clear();
  64. myNumeric->clear();
  65. myVector->clear();
  66. myMap->clear();
  67. myrParent->clear();
  68. clear();
  69. DCOUT_V( 'P', "DDLAlgorithm::processElement(...)" );
  70. }