DDLAlgorithm processes Algorithm elements. More...
#include <DDLAlgorithm.h>
Public Member Functions | |
DDLAlgorithm (DDLElementRegistry *myreg) | |
Constructor. | |
void | preProcessElement (const std::string &name, const std::string &nmspace, DDCompactView &cpv) |
Called by loadAttributes AFTER attributes are loaded. | |
void | processElement (const std::string &name, const std::string &nmspace, DDCompactView &cpv) |
Processing the element. | |
~DDLAlgorithm () | |
Destructor. |
DDLAlgorithm processes Algorithm elements.
DDLAlgorithm.h - description ------------------- begin: Saturday November 29, 2003 email: case@ucdhep.ucdavis.edu
This element is used to algorithmically create and position detector LogicalParts.
Definition at line 22 of file DDLAlgorithm.h.
DDLAlgorithm::DDLAlgorithm | ( | DDLElementRegistry * | myreg | ) |
DDLAlgorithm::~DDLAlgorithm | ( | void | ) |
void DDLAlgorithm::preProcessElement | ( | const std::string & | name, |
const std::string & | nmspace, | ||
DDCompactView & | cpv | ||
) | [virtual] |
Called by loadAttributes AFTER attributes are loaded.
The preProcessElement method can assume that the attributes are loaded and perform any code that is necessary at the start of an element.
This would allow users to call their own code to setup anything necessary for the continued processing of the child elements.
Reimplemented from DDXMLElement.
Definition at line 34 of file DDLAlgorithm.cc.
References DDXMLElement::clear(), DDLElementRegistry::getElement(), and DDXMLElement::myRegistry_.
{ myRegistry_->getElement( "Vector" )->clear(); }
void DDLAlgorithm::processElement | ( | const std::string & | name, |
const std::string & | nmspace, | ||
DDCompactView & | cpv | ||
) | [virtual] |
Processing the element.
The processElement method completes any necessary work to process the XML element.
For example, this can be used to call the DDCore to make the geometry in memory. There is a default for this so that if not declared in the inheriting class, no processing is done.
Reimplemented from DDXMLElement.
Definition at line 40 of file DDLAlgorithm.cc.
References DDXMLElement::clear(), DCOUT_V, DDAlgorithmHandler::execute(), DDXMLElement::getAttributeSet(), DDXMLElement::getDDName(), DDLElementRegistry::getElement(), DDLMap::getMapOfMaps(), DDLVector::getMapOfStrVectors(), DDLVector::getMapOfVectors(), i, DDAlgorithmHandler::initialize(), DDI::Singleton< I >::instance(), DDXMLElement::myRegistry_, and DDXMLElement::size().
{ DCOUT_V( 'P', "DDLAlgorithm::processElement started" ); DDXMLElement* myNumeric = myRegistry_->getElement( "Numeric" ); DDXMLElement* myString = myRegistry_->getElement( "String" ); DDXMLElement* myVector = myRegistry_->getElement( "Vector" ); DDXMLElement* myMap = myRegistry_->getElement( "Map" ); DDXMLElement* myrParent = myRegistry_->getElement( "rParent" ); DDName algoName( getDDName( nmspace )); DDLogicalPart lp( DDName( myrParent->getDDName( nmspace ))); DDXMLAttribute atts; // handle all Numeric elements in the Algorithm. DDNumericArguments nArgs; size_t i = 0; for( ; i < myNumeric->size(); ++i ) { atts = myNumeric->getAttributeSet( i ); nArgs[atts.find( "name" )->second] = ExprEvalSingleton::instance().eval( nmspace, atts.find( "value" )->second ); } DDStringArguments sArgs; for( i = 0; i < myString->size(); ++i ) { atts = myString->getAttributeSet( i ); sArgs[atts.find( "name" )->second] = atts.find( "value" )->second; } DDAlgorithmHandler handler; atts = getAttributeSet(); DDLVector* tv = dynamic_cast<DDLVector*>( myVector ); DDLMap* tm = dynamic_cast<DDLMap*>( myMap ); handler.initialize( algoName, lp, nArgs, tv->getMapOfVectors(), tm->getMapOfMaps(), sArgs, tv->getMapOfStrVectors()); handler.execute( cpv ); // clear used/referred to elements. myString->clear(); myNumeric->clear(); myVector->clear(); myMap->clear(); myrParent->clear(); clear(); DCOUT_V( 'P', "DDLAlgorithm::processElement(...)" ); }