This is a base class for processing XML elements in the DDD. More...
#include <DDXMLElement.h>
Public Member Functions | |
void | appendText (const std::string &inText) |
append to the current (i.e. most recently added) More... | |
virtual std::vector < DDXMLAttribute > ::const_iterator | begin (void) |
virtual void | clear (void) |
clear this element's contents. More... | |
DDXMLElement (DDLElementRegistry *myreg) | |
Constructor. More... | |
DDXMLElement (DDLElementRegistry *myreg, const bool &clearme) | |
Constructor for autoClear element. More... | |
virtual std::vector < DDXMLAttribute > ::const_iterator | end (void) |
virtual const std::string & | get (const std::string &name, size_t aIndex=0) const |
Returns a specific value from the aIndex set of attributes. More... | |
virtual const std::string & | getAttribute (const std::string &name) const |
Access to attributes by name. More... | |
virtual const DDXMLAttribute & | getAttributeSet (size_t aIndex=0) const |
Get a "row" of attributes, i.e. one attribute set. More... | |
virtual const DDName | getDDName (const std::string &defaultNS, const std::string &attname=std::string("name"), size_t aIndex=0) |
const std::string | getText (size_t tindex=0) const |
retrieve the text blob. More... | |
virtual std::vector< std::string > | getVectorAttribute (const std::string &name) |
Returns a set of values as a std::vector of strings, given the attribute name. More... | |
virtual bool | gotText (void) const |
gotText()? kind of like gotMilk? Yes = text has already been encountered. More... | |
virtual bool | isEmpty (void) const |
Have any elements of this type been encountered but not processed? More... | |
void | loadAttributes (const std::string &elemName, const std::vector< std::string > &names, const std::vector< std::string > &values, const std::string &nmspace, DDCompactView &cpv) |
Load the element attributes. More... | |
void | loadText (const std::string &inText) |
Used to load both text and XML comments into this object. More... | |
std::vector< DDXMLAttribute > ::const_iterator & | operator++ (int inc) |
Allow the elements of this type to be iterated over using ++ operator. More... | |
const std::string & | parent (void) const |
access to parent element name More... | |
virtual void | preProcessElement (const std::string &name, const std::string &nmspace, DDCompactView &cpv) |
Called by loadAttributes AFTER attributes are loaded. More... | |
virtual void | processElement (const std::string &name, const std::string &nmspace, DDCompactView &cpv) |
Processing the element. More... | |
void | setParent (const std::string &pename) |
Set parent element name to central list of names. More... | |
void | setSelf (const std::string &sename) |
Set self element name to central list of names. More... | |
virtual size_t | size (void) const |
Number of elements accumulated. More... | |
virtual void | stream (std::ostream &os) const |
Allow for the elements to have their own streaming method, but also provide a default. More... | |
void | throwError (const std::string &keyMessage) const |
format std::string for throw an error. More... | |
virtual | ~DDXMLElement (void) |
Destructor. More... | |
Static Public Member Functions | |
static std::string | itostr (int i) |
WARNING: abused by other classes in this system: yet another conversion from int to std::string... More... | |
Protected Attributes | |
DDLElementRegistry * | myRegistry_ |
Private Member Functions | |
void | appendAttributes (std::vector< std::string > &tv, const std::string &name) |
behind the scenes appending to pAttributes... More... | |
Private Attributes | |
AttrAccumType | attributeAccumulator_ |
std::vector< DDXMLAttribute > | attributes_ |
bool | autoClear_ |
std::string | myElement_ |
std::vector< DDXMLAttribute > ::const_iterator | myIter_ |
std::string | parentElement_ |
std::vector< std::string > | text_ |
Friends | |
std::ostream & | operator<< (std::ostream &os, const DDXMLElement &element) |
This is a base class for processing XML elements in the DDD.
DDXMLElement
Component of DDL XML Parsing
A DDXMLElement stores all the attributes and text of an XML element. It is designed to accumulate this information unless cleared. In other words, it accumulates sets of attributes, and allows the appending of text indefinitely, as opposed to, say, creating another class which is designed to hold a std::vector of single element information. This is contrary to the way that XML normally defines an element, but for DDL, this works fine.
One of the things that one needs to build in to each subclass is when an element needs to be cleared. For some, emptying the std::vectors should happen at the end (of the processElement method). For some, clearing is ONLY done by the parent. For example, SpecPar and its child PartSelector. or Polyhedra and its child ZSection. In some cases elements can be in one or more parent elements as well as on their own (Vector, Map). For these the processing currently depends on the parent so one must clear only as appropriate.
Definition at line 59 of file DDXMLElement.h.
DDXMLElement::DDXMLElement | ( | DDLElementRegistry * | myreg | ) |
DDXMLElement::DDXMLElement | ( | DDLElementRegistry * | myreg, |
const bool & | clearme | ||
) |
|
virtual |
|
private |
behind the scenes appending to pAttributes...
Definition at line 285 of file DDXMLElement.cc.
References attributes_, end(), and i.
Referenced by getVectorAttribute().
void DDXMLElement::appendText | ( | const std::string & | inText | ) |
append to the current (i.e. most recently added)
Definition at line 233 of file DDXMLElement.cc.
References runTheMatrix::msg, text_, and throwError().
Referenced by DDLSAX2FileHandler::characters().
|
virtual |
Definition at line 306 of file DDXMLElement.cc.
References attributes_, and myIter_.
|
virtual |
clear this element's contents.
Definition at line 65 of file DDXMLElement.cc.
References attributeAccumulator_, attributes_, and text_.
Referenced by DDLVector::clearall(), python.Vispa.Views.WidgetView.WidgetView::closeEvent(), python.Vispa.Views.BoxDecayView.BoxDecayView::closeEvent(), python.Vispa.Share.FindAlgorithm.FindAlgorithm::findUsingFindDialog(), DDLAlgorithm::preProcessElement(), DDLReflectionSolid::preProcessElement(), DDLBooleanSolid::preProcessElement(), DDLPosPart::preProcessElement(), DDLRotationSequence::preProcessElement(), DDLShapelessSolid::preProcessElement(), DDLPolyGenerator::preProcessElement(), DDLCompositeMaterial::preProcessElement(), DDLLogicalPart::preProcessElement(), DDLSpecPar::processElement(), DDLAlgorithm::processElement(), DDLAlgoPosPart::processElement(), DDLPolyGenerator::processElement(), DDLDivision::processElement(), DDLElementaryMaterial::processElement(), DDLPosPart::processElement(), DDLBooleanSolid::processElement(), DDLRotationSequence::processElement(), DDLString::processElement(), DDLNumeric::processElement(), DDLRotationAndReflection::processElement(), DDLRotationByAxis::processElement(), DDLCompositeMaterial::processElement(), DDLLogicalPart::processElement(), DDLVector::processElement(), DDLMap::processElement(), processElement(), python.Vispa.Views.LineDecayView.LineDecayView::setDataObjects(), python.Vispa.Views.WidgetView.WidgetView::setDataObjects(), DDLMaterial::setReference(), DDLSolid::setReference(), python.Vispa.Views.TreeView.TreeView::updateContent(), python.Vispa.Views.TableView.TableView::updateContent(), python.Vispa.Views.BoxDecayView.BoxDecayView::updateContent(), and python.Vispa.Views.PropertyView.PropertyView::updateContent().
|
virtual |
Definition at line 313 of file DDXMLElement.cc.
References attributes_, and myIter_.
Referenced by appendAttributes(), Types.LuminosityBlockRange::cppID(), Types.EventRange::cppID(), and get().
|
virtual |
Returns a specific value from the aIndex set of attributes.
Definition at line 159 of file DDXMLElement.cc.
References attributes_, DCOUT_V, end(), itostr(), runTheMatrix::msg, mergeVDriftHistosByStation::name, and throwError().
Referenced by Options.Options::__getitem__().
|
virtual |
Access to attributes by name.
Definition at line 74 of file DDXMLElement.cc.
References attributes_.
|
virtual |
Get a "row" of attributes, i.e. one attribute set.
Definition at line 83 of file DDXMLElement.cc.
References attributes_.
Referenced by DDLBooleanSolid::dumpBooleanSolid(), DDLRotationAndReflection::isLeftHanded(), DDLRotationAndReflection::makeX(), DDLRotationAndReflection::makeY(), DDLRotationAndReflection::makeZ(), DDLTubs::processElement(), DDLTorus::processElement(), DDLTrapezoid::processElement(), DDLPseudoTrap::processElement(), DDLSpecPar::processElement(), DDLOrb::processElement(), DDLBox::processElement(), DDLEllipsoid::processElement(), DDLEllipticalTube::processElement(), DDLAlgorithm::processElement(), DDLParallelepiped::processElement(), DDLCone::processElement(), DDLSphere::processElement(), DDLAlgoPosPart::processElement(), DDLElementaryMaterial::processElement(), DDLPolyGenerator::processElement(), DDLDivision::processElement(), DDLBooleanSolid::processElement(), DDLNumeric::processElement(), DDLString::processElement(), DDLRotationSequence::processElement(), DDLPosPart::processElement(), DDLRotationAndReflection::processElement(), DDLRotationByAxis::processElement(), DDLCompositeMaterial::processElement(), DDLLogicalPart::processElement(), DDLVector::processElement(), DDLMap::processElement(), DDLMaterial::setReference(), and DDLSolid::setReference().
|
virtual |
Definition at line 91 of file DDXMLElement.cc.
References attributes_, itostr(), runTheMatrix::msg, mergeVDriftHistosByStation::name, and throwError().
Referenced by DDLRotationAndReflection::isLeftHanded(), DDLTubs::processElement(), DDLPseudoTrap::processElement(), DDLSpecPar::processElement(), DDLTrapezoid::processElement(), DDLTorus::processElement(), DDLParallelepiped::processElement(), DDLBox::processElement(), DDLEllipsoid::processElement(), DDLReflectionSolid::processElement(), DDLAlgorithm::processElement(), DDLEllipticalTube::processElement(), DDLCone::processElement(), DDLShapelessSolid::processElement(), DDLSphere::processElement(), DDLOrb::processElement(), DDLElementaryMaterial::processElement(), DDLPolyGenerator::processElement(), DDLAlgoPosPart::processElement(), DDLDivision::processElement(), DDLPosPart::processElement(), DDLRotationSequence::processElement(), DDLNumeric::processElement(), DDLString::processElement(), DDLBooleanSolid::processElement(), DDLRotationAndReflection::processElement(), DDLRotationByAxis::processElement(), DDLCompositeMaterial::processElement(), DDLLogicalPart::processElement(), DDLVector::processElement(), and DDLMap::processElement().
const std::string DDXMLElement::getText | ( | size_t | tindex = 0 | ) | const |
retrieve the text blob.
Definition at line 247 of file DDXMLElement.cc.
References runTheMatrix::msg, text_, and throwError().
Referenced by DDLVector::processElement(), and DDLMap::processElement().
|
virtual |
Returns a set of values as a std::vector of strings, given the attribute name.
Definition at line 184 of file DDXMLElement.cc.
References appendAttributes(), attributeAccumulator_, attributes_, DCOUT_V, mergeVDriftHistosByStation::name, and size().
|
virtual |
gotText()? kind of like gotMilk? Yes = text has already been encountered.
Definition at line 257 of file DDXMLElement.cc.
References text_.
Referenced by DDLSAX2FileHandler::characters().
|
virtual |
Have any elements of this type been encountered but not processed?
Definition at line 354 of file DDXMLElement.cc.
References attributes_.
|
static |
WARNING: abused by other classes in this system: yet another conversion from int to std::string...
Definition at line 346 of file DDXMLElement.cc.
References recoMuon::in.
Referenced by DDDividedPolyconeZ::checkParametersValidity(), get(), getDDName(), DDDividedTubsRho::makeDDLogicalPart(), DDDividedConsRho::makeDDLogicalPart(), DDDividedPolyconeRho::makeDDLogicalPart(), DDDividedPolyhedraRho::makeDDLogicalPart(), DDDividedConsZ::makeDDLogicalPart(), DDDividedTrdZ::makeDDLogicalPart(), DDDividedPolyconeZ::makeDDLogicalPart(), DDDividedPolyhedraZ::makeDDLogicalPart(), DDDividedConsPhi::makeDDRotation(), DDDividedTubsPhi::makeDDRotation(), DDDividedPolyconePhi::makeDDRotation(), and DDDividedPolyhedraPhi::makeDDRotation().
void DDXMLElement::loadAttributes | ( | const std::string & | elemName, |
const std::vector< std::string > & | names, | ||
const std::vector< std::string > & | values, | ||
const std::string & | nmspace, | ||
DDCompactView & | cpv | ||
) |
Load the element attributes.
The loadAttributes method loads the attributes of the element into a std::map<std::string, std::string> which is used to store Name-Value pairs. It takes as input two std::vectors of strings containing "synchronized" names and values.
In the SAX2 based calling process, this is done on a startElement event.
Definition at line 44 of file DDXMLElement.cc.
References attributes_, DCOUT_V, i, and preProcessElement().
Referenced by DDLRotationByAxis::processElement(), DDLMaterial::setReference(), DDLSolid::setReference(), and DDLSAX2FileHandler::startElement().
void DDXMLElement::loadText | ( | const std::string & | inText | ) |
Used to load both text and XML comments into this object.
At the current time this is done simply as a way for the user of this class to accumulate text and/or comments as std::vector of strings, each one matching the std::vector of attributes. Therefore loadText starts a new text storage.
Definition at line 226 of file DDXMLElement.cc.
References text_.
Referenced by DDLSAX2FileHandler::characters(), processElement(), and DDLSAX2FileHandler::startElement().
std::vector< DDXMLAttribute >::const_iterator & DDXMLElement::operator++ | ( | int | inc | ) |
Allow the elements of this type to be iterated over using ++ operator.
Definition at line 320 of file DDXMLElement.cc.
References myIter_.
const std::string & DDXMLElement::parent | ( | void | ) | const |
access to parent element name
Definition at line 327 of file DDXMLElement.cc.
References parentElement_.
Referenced by python.Vispa.Gui.ConnectableWidget.ConnectableWidget::addMenuEntry(), python.Vispa.Views.LineDecayView.LineDecayContainer::applyFilter(), python.Vispa.Views.BoxDecayView.BoxDecayContainer::arrangeUsingRelations(), python.Vispa.Views.BoxDecayView.BoxDecayContainer::autolayoutAlgorithm(), python.Vispa.Gui.ZoomableScrollableWidgetOwner.ZoomableScrollableWidgetOwner::autosizeScrollArea(), python.Vispa.Views.BoxDecayView.BoxDecayContainer::autosizeScrollArea(), python.Vispa.Gui.PortWidget.PortWidget::connectionPoint(), python.Vispa.Main.StartupScreen.StartupScreen::createDescriptionWidget(), python.Vispa.Views.BoxDecayView.BoxDecayContainer::dataAccessor(), python.Vispa.Views.LineDecayView.LineDecayContainer::dataAccessor(), python.Vispa.Views.LineDecayView.DecayLine::dataAccessor(), python.Vispa.Views.LineDecayView.LineDecayContainer::delete(), python.Vispa.Views.LineDecayView.DecayNode::delete(), python.Vispa.Views.LineDecayView.DecayLine::delete(), python.Vispa.Gui.VispaWidget.VispaWidget::delete(), python.Vispa.Gui.VispaWidget.VispaWidget::dragWidget(), python.Vispa.Share.ImageExporter.ImageExporter::exportImageDialog(), python.Vispa.Views.LineDecayView.DecayLine::extendedSize(), python.Vispa.Gui.VispaWidget.VispaWidget::keyPressEvent(), python.Vispa.Gui.MenuWidget.MenuWidget::leaveEvent(), python.Vispa.Gui.ConnectableWidget.ConnectableWidget::leaveEvent(), python.Vispa.Gui.PortWidget.PortWidget::moduleParent(), python.Vispa.Gui.WidgetContainer.WidgetContainer::mouseDoubleClickEvent(), python.Vispa.Gui.VispaWidget.VispaWidget::mouseDoubleClickEvent(), python.Vispa.Gui.PortConnection.PointToPointConnection::mousePressEvent(), python.Vispa.Gui.VispaWidget.VispaWidget::mousePressEvent(), python.Vispa.Views.LineDecayView.ParticleWidget::mousePressEvent(), python.Vispa.Views.LineDecayView.DecayNode::move(), python.Vispa.Views.LineDecayView.LineDecayContainer::noDecorationsMode(), python.Vispa.Views.LineDecayView.LineDecayContainer::operationId(), python.Vispa.Views.LineDecayView.DecayLine::paint(), python.Vispa.Gui.VispaWidget.VispaWidget::paintEvent(), python.Vispa.Gui.ConnectableWidget.ConnectableWidget::positionizeMenuWidget(), DDLDivision::processElement(), DDLAlgoPosPart::processElement(), DDLNumeric::processElement(), DDLString::processElement(), DDLRotationByAxis::processElement(), DDLVector::processElement(), DDLMap::processElement(), python.Vispa.Views.LineDecayView.DecayLine::qtLineStyle(), python.Vispa.Views.WidgetView.WidgetView::restoreSelection(), python.Vispa.Views.WidgetView.WidgetView::select(), python.Vispa.Gui.PortConnection.PointToPointConnection::select(), python.Vispa.Gui.VispaWidget.VispaWidget::select(), python.Vispa.Views.LineDecayView.LineDecayContainer::select(), DDLSolid::setReference(), python.Vispa.Views.LineDecayView.LineDecayContainer::sizeHint(), python.Vispa.Views.LineDecayView.LineDecayContainer::tabController(), python.Vispa.Views.BoxDecayView.BoxDecayContainer::toggleCollapsed(), python.Vispa.Views.LineDecayView.DecayNode::unite(), python.Vispa.Views.PropertyView.PropertyView::valueChanged(), python.Vispa.Views.BoxDecayView.BoxDecayContainer::widgetByObject(), python.Vispa.Gui.VispaWidgetOwner.VispaWidgetOwner::widgetDoubleClicked(), and python.Vispa.Gui.VispaWidgetOwner.VispaWidgetOwner::widgetDragged().
|
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 in DDLMap, DDLVector, DDLLogicalPart, DDLCompositeMaterial, DDLPolyGenerator, DDLRotationByAxis, DDLShapelessSolid, DDLBooleanSolid, DDLNumeric, DDLPosPart, DDLRotationSequence, DDLString, DDLDivision, DDLReflectionSolid, and DDLAlgorithm.
Definition at line 37 of file DDXMLElement.cc.
References DCOUT_V.
Referenced by loadAttributes().
|
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 in DDLMap, DDLVector, DDLLogicalPart, DDLCompositeMaterial, DDLRotationByAxis, DDLRotationAndReflection, DDLBooleanSolid, DDLNumeric, DDLPosPart, DDLRotationSequence, DDLString, DDLAlgoPosPart, DDLDivision, DDLElementaryMaterial, DDLPolyGenerator, DDLAlgorithm, DDLBox, DDLCone, DDLEllipsoid, DDLEllipticalTube, DDLOrb, DDLParallelepiped, DDLReflectionSolid, DDLShapelessSolid, DDLSphere, DDLPseudoTrap, DDLSpecPar, DDLTorus, DDLTrapezoid, and DDLTubs.
Definition at line 217 of file DDXMLElement.cc.
References autoClear_, clear(), DCOUT_V, and loadText().
Referenced by DDLSAX2FileHandler::endElement().
void DDXMLElement::setParent | ( | const std::string & | pename | ) |
Set parent element name to central list of names.
Definition at line 333 of file DDXMLElement.cc.
References parentElement_.
Referenced by DDLSAX2FileHandler::endElement().
void DDXMLElement::setSelf | ( | const std::string & | sename | ) |
Set self element name to central list of names.
Definition at line 339 of file DDXMLElement.cc.
References myElement_.
Referenced by DDLSAX2FileHandler::endElement().
|
virtual |
Number of elements accumulated.
Definition at line 300 of file DDXMLElement.cc.
References attributes_.
Referenced by DDLBooleanSolid::dumpBooleanSolid(), getVectorAttribute(), DDLSpecPar::processElement(), DDLReflectionSolid::processElement(), DDLAlgorithm::processElement(), DDLAlgoPosPart::processElement(), DDLPolyGenerator::processElement(), DDLPosPart::processElement(), DDLRotationSequence::processElement(), DDLBooleanSolid::processElement(), DDLCompositeMaterial::processElement(), and DDLMaterial::setReference().
|
virtual |
Allow for the elements to have their own streaming method, but also provide a default.
Definition at line 271 of file DDXMLElement.cc.
References attributes_.
Referenced by operator<<().
void DDXMLElement::throwError | ( | const std::string & | keyMessage | ) | const |
format std::string for throw an error.
Definition at line 360 of file DDXMLElement.cc.
References runTheMatrix::msg, and myElement_.
Referenced by appendText(), DDLVector::errorOut(), DDLMap::errorOut(), get(), getDDName(), getText(), DDLDivision::makeDivider(), DDLTubs::processElement(), DDLTrapezoid::processElement(), DDLDivision::processElement(), DDLPolyGenerator::processElement(), DDLAlgoPosPart::processElement(), DDLBooleanSolid::processElement(), DDLRotationAndReflection::processElement(), DDLCompositeMaterial::processElement(), and DDLRotationByAxis::processOne().
|
friend |
Definition at line 264 of file DDXMLElement.cc.
|
private |
Definition at line 195 of file DDXMLElement.h.
Referenced by clear(), and getVectorAttribute().
|
private |
Definition at line 193 of file DDXMLElement.h.
Referenced by appendAttributes(), begin(), clear(), end(), get(), getAttribute(), getAttributeSet(), getDDName(), getVectorAttribute(), isEmpty(), loadAttributes(), size(), and stream().
|
private |
Definition at line 196 of file DDXMLElement.h.
Referenced by processElement().
|
private |
Definition at line 198 of file DDXMLElement.h.
Referenced by setSelf(), and throwError().
|
private |
Definition at line 197 of file DDXMLElement.h.
Referenced by begin(), end(), and operator++().
|
protected |
Definition at line 187 of file DDXMLElement.h.
Referenced by DDLBooleanSolid::dumpBooleanSolid(), DDLAlgorithm::preProcessElement(), DDLReflectionSolid::preProcessElement(), DDLBooleanSolid::preProcessElement(), DDLRotationSequence::preProcessElement(), DDLPosPart::preProcessElement(), DDLShapelessSolid::preProcessElement(), DDLPolyGenerator::preProcessElement(), DDLCompositeMaterial::preProcessElement(), DDLLogicalPart::preProcessElement(), DDLSpecPar::processElement(), DDLReflectionSolid::processElement(), DDLAlgorithm::processElement(), DDLAlgoPosPart::processElement(), DDLPolyGenerator::processElement(), DDLRotationSequence::processElement(), DDLBooleanSolid::processElement(), DDLPosPart::processElement(), DDLRotationByAxis::processElement(), DDLCompositeMaterial::processElement(), DDLLogicalPart::processElement(), DDLMaterial::setReference(), and DDLSolid::setReference().
|
private |
Definition at line 199 of file DDXMLElement.h.
Referenced by parent(), and setParent().
|
private |
Definition at line 194 of file DDXMLElement.h.
Referenced by appendText(), clear(), getText(), gotText(), and loadText().