Class which determines the agent properties for each new agent.
More...
#include <AgentInitializer.h>
|
static bool | VERBOSE = false |
| Determines if the agent properties parsing process will be verbose.
|
|
|
virtual bool | isRelevant (const ::std::string &tagName) |
| Reports if this AgentInitializer cares about the given AgentSet property XML tag. More...
|
|
virtual ParseResult | setFromXMLAttribute (const ::std::string ¶mName, const ::std::string &value) |
| Defines a constant value for an agent property as specified by the attribute of an agent property tag. More...
|
|
bool | parsePropertySpec (TiXmlElement *node) |
| Parses the Property tag that is the child of an AgentSet Parameter tag. More...
|
|
virtual ParseResult | processProperty (::std::string propName, TiXmlElement *node) |
| Process the given <Property .../> tag. More...
|
|
ParseResult | constFloatGenerator (FloatGenerator *&gen, const ::std::string &valueStr, float scale=1.f) |
| Helper function for setting a property from an xml attribute. More...
|
|
ParseResult | constFloat (float &numValue, const ::std::string &valueStr, float scale=1.f) |
| Helper function for setting a property from an xml attribute. More...
|
|
ParseResult | constIntGenerator (IntGenerator *&gen, const ::std::string &valueStr) |
| Helper function for setting a property from an xml attribute. More...
|
|
ParseResult | constSizet (size_t &numValue, const ::std::string &valueStr) |
| Helper function for setting a property from an xml attribute. More...
|
|
ParseResult | getFloatGenerator (FloatGenerator *&gen, TiXmlElement *node, float scale=1.f) |
| Helper function for setting a property from an xml Property node. More...
|
|
ParseResult | getIntGenerator (IntGenerator *&gen, TiXmlElement *node) |
| Helper function for setting a property from an xml Property node. More...
|
|
Class which determines the agent properties for each new agent.
This base agent intializer class facilitates setting all BaseAgent properties. The property values are set using number generators (see RandGenerator.h).
Return type for parsing efforts. Helps the various derived classes coordinate their work.
Enumerator |
---|
FAILURE |
The parsing ended in failure.
|
IGNORED |
The XML data was ignored by the function.
|
ACCEPTED |
The XML data was accepted by the function.
|
Menge::Agents::AgentInitializer::AgentInitializer |
( |
| ) |
|
Constructor.
The values for each agent take a hard-coded default values.
Menge::Agents::AgentInitializer::AgentInitializer |
( |
const AgentInitializer & |
init | ) |
|
Copy Constructor.
- Parameters
-
AgentInitializer::ParseResult Menge::Agents::AgentInitializer::constFloat |
( |
float & |
numValue, |
|
|
const ::std::string & |
valueStr, |
|
|
float |
scale = 1.f |
|
) |
| |
|
protected |
Helper function for setting a property from an xml attribute.
This is used to parse and create a value generator in the case where the attribute is defined on the main property tag: e.g.,
<Common property="value.../>
- Parameters
-
numValue | The new float will be put into this variable. |
valueStr | The string representing the attribute value to convert to a const float generator. |
scale | Optional argument for changing the units of the input value. (e.g., specification commonly describes angles as degrees, but internal representation is in radians). |
- Returns
- A parse result indicating either ACCEPTED or FAILURE. IGNORED should never be a result, because it should only be called on expected parameters, so it must either succed or fail.
Helper function for setting a property from an xml attribute.
This is used to parse and create a value generator in the case where the attribute is defined on the main property tag: e.g.,
<Common property="value.../>
- Parameters
-
gen | A reference to a pointer to a valid FloatGenerator. The new float generator will be put into this variable. |
valueStr | The string representing the attribute value to convert to a const float generator. |
scale | Optional argument for changing the units of the input value. (e.g., specification commonly describes angles as degrees, but internal representation is in radians). |
- Returns
- A parse result indicating either ACCEPTED or FAILURE. IGNORED should never be a result, because it should only be called on expected parameters, so it must either succed or fail.
Helper function for setting a property from an xml attribute.
This is used to parse and create a value generator in the case where the attribute is defined on the main property tag: e.g.,
<Common property="value.../>
- Parameters
-
gen | A reference to a pointer to a valid IntGenerator. The new int generator will be put into this variable. |
valueStr | The string representing the attribute value to convert to a const float generator. |
- Returns
- A parse result indicating either ACCEPTED or FAILURE. IGNORED should never be a result, because it should only be called on expected parameters, so it must either succed or fail.
Helper function for setting a property from an xml attribute.
This is used to parse and create a value generator in the case where the attribute is defined on the main property tag: e.g.,
<Common property="value.../>
- Parameters
-
numValue | The new size_t will be put into this variable. |
valueStr | The string representing the attribute value to convert to a const float generator. |
- Returns
- A parse result indicating either ACCEPTED or FAILURE. IGNORED should never be a result, because it should only be called on expected parameters, so it must either succed or fail.
Helper function for setting a property from an xml Property node.
This is used to parse and create a value generator in the case where the attribute is defined explicitly as a distribution on a Property tag, e.g.,
<Property name="property" dist="x".../>
- Parameters
-
gen | A reference to a pointer to a valid FloatGenerator. The new float generator will be put into this variable. |
node | The xml node containing attributes for the distribution specification. |
scale | Optional argument for changing the units of the input value. (e.g., specification commonly describes angles as degrees, but internal representation is in radians). |
- Returns
- A parse result indicating either ACCEPTED or FAILURE. IGNORED should never be a result, because it should only be called on expected parameters, so it must either succed or fail.
Helper function for setting a property from an xml Property node.
This is used to parse and create a value generator in the case where the attribute is defined on the main property tag: e.g.,
<Common property="value.../>
- Parameters
-
gen | A reference to a pointer to a valid IntGenerator. The new int generator will be put into this variable. |
node | The xml node containing attributes for the distribution specification. |
- Returns
- A parse result indicating either ACCEPTED or FAILURE. IGNORED should never be a result, because it should only be called on expected parameters, so it must either succed or fail.
bool Menge::Agents::AgentInitializer::isRelevant |
( |
const ::std::string & |
tagName | ) |
|
|
protectedvirtual |
Reports if this AgentInitializer cares about the given AgentSet property XML tag.
This is the mechanism by which new sub-classes can extend the parameter space. Each pedestrian model which introduces new per-agent properties that must override this function. However, the overriden function must, in turn, call the parent class if it doesn't consider the tag relevant, giving the parent class a chance to determine if the tag is relevant. This is the mechanism by which derived classes will also benefit from the <Common>
parameter set.
- Parameters
-
tagName | The name of the tag to test. |
- Returns
- True if the tag is relevant, false otherwise.
Reimplemented in ORCA::AgentInitializer, and PedVO::AgentInitializer.
bool Menge::Agents::AgentInitializer::parseProperties |
( |
TiXmlElement * |
node, |
|
|
const std::string & |
sceneFldr |
|
) |
| |
Parses an AgentSet property tag, setting agent values as appropriate.
This function can be called on all AgentSet property tags. The function is responsible for determining which tags have relevant information and which are to be ignored.
If a tag is deemed to be relevant, but the content of the tag is incorrect, such as a mal-formed property definition, then the parsing "fails". However, unexpected property attributes or specifications will be ignored. If the system is running in verbose mode, these unexpected attributes will be indicated on the console.
Such a tag could look like this:
<Common r="0.1" class="2" ... />
or
<Common r="0.1" class="2" ... >
<Property type="radius" dist="u" min="0.18" max="0.2"/>
<Property type="prefSpeed" dist="n" mean="1.34" stddev="0.2"/>
</Common>
- Parameters
-
node | The xml node containing agent properties for an AgentSet. |
sceneFldr | Since we now need access to resources at this stage, we pass the base folder for resource loading |
- Returns
- True if parsing was "successful", false otherwise.
bool Menge::Agents::AgentInitializer::parsePropertySpec |
( |
TiXmlElement * |
node | ) |
|
|
protected |
Parses the Property tag that is the child of an AgentSet Parameter tag.
As with the other parsing code, success is defined by finding an expected, correct field or an unexpected tag (which is just ignored). Failure occurs when the tags are as expected, but the values are invalid.
- Parameters
-
node | The xml node containing agent properties for an AgentSet. |
- Returns
- True if parsing was "successful", false otherwise.
Process the given <Property .../>
tag.
As a pre-condition to this function, the XML node contains a <Property.../>
tag and has been confirmed to have, at least, a name attribute. Nothing else about the tag has been validated.
If the property name is unexpected, it will be ignored. If it is expected, this function will attempt to interpret the XML tag as a number distribution for a valid agent attribute. If it can do so, it is successful, if it can't, it fails.
- Parameters
-
propName | The extracted "name" attribute from the Property tag. |
node | The XML node for the Property tag. |
- Returns
- The ParseResult indicating if the property was successful (IGNORED or ACCEPTED) or if it was a malformed tag (FAILURE).
Reimplemented in ORCA::AgentInitializer, and PedVO::AgentInitializer.
void Menge::Agents::AgentInitializer::setDefaults |
( |
| ) |
|
|
virtual |
Sets all generators to default values.
Resets all number generators to default const values. This assumes that all required number generators already exist and will delete them appropriately. Do not call this in the constructor.
Reimplemented in ORCA::AgentInitializer, and PedVO::AgentInitializer.
AgentInitializer::ParseResult Menge::Agents::AgentInitializer::setFromXMLAttribute |
( |
const ::std::string & |
paramName, |
|
|
const ::std::string & |
value |
|
) |
| |
|
protectedvirtual |
Defines a constant value for an agent property as specified by the attribute of an agent property tag.
Derived classes should override this function, but possibly call the parent class's implementation. First, it should test to see if the paramName is expected by the derived class. If so, the derived class can determine fail or accept. If it is not expected, it should call the parent class's implementation and returns its value.
- Parameters
-
paramName | A string containing the parameter name. |
value | A string containing the value for the parameter. |
- Returns
- The result of the parse: failure, ignored, or accepted.
Reimplemented in ORCA::AgentInitializer, and PedVO::AgentInitializer.
bool Menge::Agents::AgentInitializer::setProperties |
( |
BaseAgent * |
agent | ) |
|
|
virtual |
Sets the properties of the given agent based on the initializer's values.
This needs to be overridden by sub-classes. The first thing the sub-class should do is dynamic_cast the argument to its expected type to make sure it is the proper agent type. If not, this should be considered failure. Then it should set its unique properties and then call the super class's setProperties function.
- Parameters
-
agent | The agent whose properties are to be set. |
- Returns
- True if the properties were set successfully, false otherwise.
Reimplemented in ORCA::AgentInitializer, and PedVO::AgentInitializer.
The documentation for this class was generated from the following files:
- src/menge/MengeCore/Agents/AgentInitializer.h
- src/menge/MengeCore/Agents/AgentInitializer.cpp