Menge
Modular Pedestrian Simulation Framework for Research and Development
|
An element attribute. More...
#include <Attribute.h>
Public Member Functions | |
Attribute (const std::string &name, bool required) | |
Constructor. More... | |
virtual | ~Attribute () |
Destructor. | |
virtual bool | extract (TiXmlElement *node)=0 |
Extracts the values for this attribute from the xml node. More... | |
const std::string & | getName () const |
Returns a const reference to the name of the attribute. More... | |
bool | isRequired () const |
Reports if this attribute is required to be specified. More... | |
bool | isValid () const |
Reports if the attribute is valid. More... | |
void | clear () |
Prepares the attribute for a parse attempt. | |
virtual void | setDefault ()=0 |
If defined, sets the default value for the attribute. | |
virtual int | getInt () |
Retrieve the parsed int value. More... | |
virtual bool | getBool () |
Retrieve the parsed boolean value. More... | |
virtual float | getFloat () |
Retrieve the parsed float value. More... | |
virtual std::string | getString () |
Retrieve the parsed string value. More... | |
virtual size_t | getSizeT () |
Retrieve the parsed size_t value. More... | |
virtual FloatGenerator * | getFloatGenerator () |
Retrieve the parsed float generator. More... | |
virtual Vec2DGenerator * | getVec2DGenerator () |
Retrieve the parsed 2D float generator. More... | |
virtual IntGenerator * | getIntGenerator () |
Retrieve the parsed int generator. More... | |
Protected Attributes | |
std::string | _name |
The name of the xml attribute. | |
bool | _required |
Determines if the XML must specify this attribute. | |
bool | _valid |
Reports if the attribute is valid. An attribute is always valid if it is not required. Otherwise, it is only valid if it was able to be initialized from the XML. | |
An element attribute.
This serves as a simple mechanism to configure XML parsing for elements who only require simple xml-parameter-style arguments. See AttributeSet for proper user. This is the entity responsible for parsing the XML and extracting the value specified.
The Attribute also stores the parsed value and reports on its own "validity". The validity of an Attribute is based on whether it is set to be "required" (i.e., the user must explicitly specify a value). If a required attribute is not defined in the XML, then it is invalid.
|
inline |
Constructor.
name | The attribute name - used in parsing XML attributes. |
required | Whether or not the attribute is required (true) or not (false). |
|
pure virtual |
Extracts the values for this attribute from the xml node.
This is the main parsing work. It must be performed by each attribute sub-class.
node | The XML node containing the attributes. |
Implemented in Menge::IntDistributionAttribute, Menge::Vec2DDistributionAttribute, Menge::FloatDistributionAttribute, Menge::SizeTAttribute, Menge::BoolAttribute, Menge::FloatAttribute, Menge::IntAttribute, and Menge::StringAttribute.
|
inlinevirtual |
Retrieve the parsed boolean value.
If the type of this attribute is not a bool, an exception will be thrown.
An | AttributeDefinitionException if the types are wrong. |
Reimplemented in Menge::BoolAttribute.
|
inlinevirtual |
Retrieve the parsed float value.
If the type of this attribute is not a float, an exception will be thrown.
An | AttributeDefinitionException if the types are wrong. |
Reimplemented in Menge::FloatAttribute.
|
inlinevirtual |
Retrieve the parsed float generator.
If the type of this attribute is not a float generator, an exception will be thrown.
An | AttributeDefinitionException if the types are wrong. |
Reimplemented in Menge::FloatDistributionAttribute.
|
inlinevirtual |
Retrieve the parsed int value.
If the type of this attribute is not an int, an exception will be thrown.
An | AttributeDefinitionException if the types are wrong. |
Reimplemented in Menge::IntAttribute.
|
inlinevirtual |
Retrieve the parsed int generator.
If the type of this attribute is not an int generator, an exception will be thrown.
An | AttributeDefinitionException if the types are wrong. |
Reimplemented in Menge::IntDistributionAttribute.
|
inline |
Returns a const reference to the name of the attribute.
|
inlinevirtual |
Retrieve the parsed size_t value.
If the type of this attribute is not a size_t, an exception will be thrown.
An | AttributeDefinitionException if the types are wrong. |
Reimplemented in Menge::SizeTAttribute.
|
inlinevirtual |
Retrieve the parsed string value.
If the type of this attribute is not a string, an exception will be thrown.
An | AttributeDefinitionException if the types are wrong. |
Reimplemented in Menge::StringAttribute.
|
inlinevirtual |
Retrieve the parsed 2D float generator.
An | AttributeDefinitionException if the types are wrong. |
Reimplemented in Menge::Vec2DDistributionAttribute.
|
inline |
Reports if this attribute is required to be specified.
|
inline |
Reports if the attribute is valid.