DDLAlgoPosPart handles AlgoPosPart elements. More...
#include <DDLAlgoPosPart.h>
Public Member Functions | |
DDLAlgoPosPart (DDLElementRegistry *myreg) | |
Constructor. | |
void | processElement (const std::string &name, const std::string &nmspace, DDCompactView &cpv) |
Processing the element. | |
~DDLAlgoPosPart () | |
Destructor. |
DDLAlgoPosPart handles AlgoPosPart elements.
DDLAlgoPosPart.h - description ------------------- begin: Wed Apr 17 2002 email: case@ucdhep.ucdavis.edu
An AlgoPosPart (or Algorithmic Positioning Part) is used to repeatedly position a LogicalPart somewhere inside it's parent. So, an AlgoPosPart needs two rLogicalParts (self and parent) on which to operate, an Algorithm and it's parameters.
Definition at line 25 of file DDLAlgoPosPart.h.
DDLAlgoPosPart::DDLAlgoPosPart | ( | DDLElementRegistry * | myreg | ) |
DDLAlgoPosPart::~DDLAlgoPosPart | ( | void | ) |
void DDLAlgoPosPart::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 36 of file DDLAlgoPosPart.cc.
References algo, DDCompactView::algoPosPart(), DDXMLElement::clear(), DCOUT_V, ExprEvalInterface::eval(), DDXMLElement::getAttributeSet(), DDXMLElement::getDDName(), DDLElementRegistry::getElement(), i, instance, DDBase< N, C >::isDefined(), lumiQueryAPI::msg, DDXMLElement::myRegistry_, DDXMLElement::parent(), DDAlgo::setParameters(), DDXMLElement::size(), and DDXMLElement::throwError().
{ DCOUT_V('P', "DDLAlgoPosPart::processElement started"); // get all internal elements. DDXMLElement* myParent = myRegistry_->getElement("rParent"); DDXMLElement* myChild = myRegistry_->getElement("rChild"); DDXMLElement* myParS = myRegistry_->getElement("ParS"); DDXMLElement* myParE = myRegistry_->getElement("ParE"); ExprEvalInterface & ev = ExprEvalSingleton::instance(); DDXMLAttribute atts = getAttributeSet(); // these were doubles int st = static_cast<int> ((atts.find("start") == atts.end() ? 0.0 : ev.eval(nmspace, atts.find("start")->second))); int ic = static_cast<int> ((atts.find("incr") == atts.end() ? 0.0 : ev.eval(nmspace, atts.find("incr")->second))); int ed = static_cast<int> ((atts.find("end") == atts.end() ? 0.0 : ev.eval(nmspace, atts.find("end")->second))); // get actual DDLogicalPart objects. DDLogicalPart parent(DDName(myParent->getDDName(nmspace))); DDLogicalPart self(DDName(myChild->getDDName(nmspace))); // get the algorithm DDAlgo algo( getDDName(nmspace, "algo" )); if (!(algo.isDefined().second)) { std::string msg = std::string("\n\tDDLParser, algo requested is not defined. Either AlgoInit() or check algo spelling.\n ") + "\n\t\talgo=" + std::string(getDDName(nmspace, "algo" )) + "\n\t\tparent=" + std::string(myParent->getDDName(nmspace)) + "\n\t\tself=" + std::string(myChild->getDDName(nmspace)); throwError(msg); } // set the parameters for the algorithm // First for ParE type parE_type parE; for (size_t i = 0; i < myParE->size(); ++i) { atts = myParE->getAttributeSet(i); // find vname in ParE. parE_type::iterator existingName=parE.find(atts.find("name")->second); // if found, get std::vector, then add this value to it. // if not found, add this var, then add a value to it. if (existingName != parE.end()) existingName->second.push_back(ev.eval(nmspace,atts.find("value")->second)); // tvect = existingName->second; else { std::vector<double> tvect; tvect.push_back(ev.eval(nmspace,atts.find("value")->second)); parE[atts.find("name")->second] = tvect; } } // Now for ParS type parS_type parS; for (size_t i = 0; i < myParS->size(); ++i) { atts = myParS->getAttributeSet(i); // find vname in ParS. parS_type::iterator existingName=parS.find(atts.find("name")->second); // if found, get std::vector, then add this value to it. // if not found, add this var, then add a value to it. if (existingName != parS.end()) existingName->second.push_back(atts.find("value")->second); else { std::vector<std::string> tvect; tvect.push_back(atts.find("value")->second); parS[atts.find("name")->second] = tvect; } } algo.setParameters(st,ed,ic,parS,parE); // for efficiency, I do not want to make a DDAlgoPositioner every time this is called. // so DDCompactView must have a way to position inside itself as well. cpv.algoPosPart(self, parent, algo); // ap_(self, parent, algo); // clear all "children" and attributes myChild->clear(); myParent->clear(); myParS->clear(); myParE->clear(); // after an AlgoPosPart, we are sure it can be cleared. clear(); DCOUT_V('P', "DDLAlgoPosPart::processElement completed"); }