CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Member Functions | Static Public Member Functions | Protected Attributes | Private Member Functions | Private Attributes | Friends
DDXMLElement Class Reference

This is a base class for processing XML elements in the DDD. More...

#include <DDXMLElement.h>

Inheritance diagram for DDXMLElement:
DDLAlgorithm DDLDivision DDLLogicalPart DDLMap DDLMaterial DDLNumeric DDLPosPart DDLRotationAndReflection DDLRotationByAxis DDLSolid DDLSpecPar DDLString DDLVector

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 DDXMLAttributegetAttributeSet (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

DDLElementRegistrymyRegistry_
 

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< DDXMLAttributeattributes_
 
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)
 

Detailed Description

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 58 of file DDXMLElement.h.

Constructor & Destructor Documentation

DDXMLElement::DDXMLElement ( DDLElementRegistry myreg)

Constructor.

Definition at line 15 of file DDXMLElement.cc.

DDXMLElement::DDXMLElement ( DDLElementRegistry myreg,
const bool &  clearme 
)

Constructor for autoClear element.

Definition at line 22 of file DDXMLElement.cc.

DDXMLElement::~DDXMLElement ( void  )
virtual

Destructor.

Definition at line 29 of file DDXMLElement.cc.

Member Function Documentation

void DDXMLElement::appendAttributes ( std::vector< std::string > &  tv,
const std::string &  name 
)
private

behind the scenes appending to pAttributes...

Definition at line 244 of file DDXMLElement.cc.

void DDXMLElement::appendText ( const std::string &  inText)

append to the current (i.e. most recently added)

Definition at line 192 of file DDXMLElement.cc.

std::vector< DDXMLAttribute >::const_iterator DDXMLElement::begin ( void  )
virtual

Definition at line 265 of file DDXMLElement.cc.

void DDXMLElement::clear ( void  )
virtual
std::vector< DDXMLAttribute >::const_iterator DDXMLElement::end ( void  )
virtual

Definition at line 272 of file DDXMLElement.cc.

const std::string & DDXMLElement::get ( const std::string &  name,
size_t  aIndex = 0 
) const
virtual

Returns a specific value from the aIndex set of attributes.

Definition at line 119 of file DDXMLElement.cc.

Referenced by Options.Options::__getitem__().

const std::string & DDXMLElement::getAttribute ( const std::string &  name) const
virtual

Access to attributes by name.

Definition at line 70 of file DDXMLElement.cc.

const DDXMLAttribute & DDXMLElement::getAttributeSet ( size_t  aIndex = 0) const
virtual
const DDName DDXMLElement::getDDName ( const std::string &  defaultNS,
const std::string &  attname = std::string( "name" ),
size_t  aIndex = 0 
)
virtual
const std::string DDXMLElement::getText ( size_t  tindex = 0) const

retrieve the text blob.

Definition at line 206 of file DDXMLElement.cc.

Referenced by DDLMap::processElement().

std::vector< std::string > DDXMLElement::getVectorAttribute ( const std::string &  name)
virtual

Returns a set of values as a std::vector of strings, given the attribute name.

Definition at line 144 of file DDXMLElement.cc.

bool DDXMLElement::gotText ( void  ) const
virtual

gotText()? kind of like gotMilk? Yes = text has already been encountered.

Definition at line 216 of file DDXMLElement.cc.

bool DDXMLElement::isEmpty ( void  ) const
virtual

Have any elements of this type been encountered but not processed?

Definition at line 313 of file DDXMLElement.cc.

std::string DDXMLElement::itostr ( int  i)
static

WARNING: abused by other classes in this system: yet another conversion from int to std::string...

Definition at line 305 of file DDXMLElement.cc.

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 41 of file DDXMLElement.cc.

Referenced by DDLRotationByAxis::processElement(), DDLMaterial::setReference(), and DDLSolid::setReference().

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 186 of file DDXMLElement.cc.

std::vector< DDXMLAttribute >::const_iterator & DDXMLElement::operator++ ( int  inc)

Allow the elements of this type to be iterated over using ++ operator.

Definition at line 279 of file DDXMLElement.cc.

const std::string & DDXMLElement::parent ( void  ) const
void DDXMLElement::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 in DDLMap, DDLVector, DDLLogicalPart, DDLCompositeMaterial, DDLPolyGenerator, DDLRotationByAxis, DDLShapelessSolid, DDLBooleanSolid, DDLNumeric, DDLPosPart, DDLRotationSequence, DDLString, DDLDivision, DDLReflectionSolid, and DDLAlgorithm.

Definition at line 34 of file DDXMLElement.cc.

void DDXMLElement::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 in DDLMap, DDLVector, DDLLogicalPart, DDLCompositeMaterial, DDLRotationByAxis, DDLRotationAndReflection, DDLBooleanSolid, DDLNumeric, DDLPosPart, DDLRotationSequence, DDLString, DDLDivision, DDLElementaryMaterial, DDLPolyGenerator, DDLAlgorithm, DDLBox, DDLCone, DDLEllipsoid, DDLEllipticalTube, DDLOrb, DDLParallelepiped, DDLReflectionSolid, DDLShapelessSolid, DDLSphere, DDLPseudoTrap, DDLSpecPar, DDLTorus, DDLTrapezoid, and DDLTubs.

Definition at line 177 of file DDXMLElement.cc.

void DDXMLElement::setParent ( const std::string &  pename)

Set parent element name to central list of names.

Definition at line 292 of file DDXMLElement.cc.

Referenced by lumiQTWidget.LumiCanvas::__init__().

void DDXMLElement::setSelf ( const std::string &  sename)

Set self element name to central list of names.

Definition at line 298 of file DDXMLElement.cc.

size_t DDXMLElement::size ( void  ) const
virtual
void DDXMLElement::stream ( std::ostream &  os) const
virtual

Allow for the elements to have their own streaming method, but also provide a default.

Definition at line 230 of file DDXMLElement.cc.

void DDXMLElement::throwError ( const std::string &  keyMessage) const

Friends And Related Function Documentation

std::ostream& operator<< ( std::ostream &  os,
const DDXMLElement element 
)
friend

Definition at line 223 of file DDXMLElement.cc.

Member Data Documentation

AttrAccumType DDXMLElement::attributeAccumulator_
private

Definition at line 194 of file DDXMLElement.h.

std::vector<DDXMLAttribute> DDXMLElement::attributes_
private

Definition at line 192 of file DDXMLElement.h.

bool DDXMLElement::autoClear_
private

Definition at line 195 of file DDXMLElement.h.

std::string DDXMLElement::myElement_
private

Definition at line 197 of file DDXMLElement.h.

std::vector<DDXMLAttribute>::const_iterator DDXMLElement::myIter_
private

Definition at line 196 of file DDXMLElement.h.

DDLElementRegistry* DDXMLElement::myRegistry_
protected
std::string DDXMLElement::parentElement_
private

Definition at line 198 of file DDXMLElement.h.

std::vector<std::string> DDXMLElement::text_
private

Definition at line 193 of file DDXMLElement.h.