Menge Plugin Examples
A Collection of Example Plugins for the Menge Framework
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Pages
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
Johansson::AgentInitializer Class Reference

Class which determines the agent properties for each new Johansson agent. More...

#include <JohanssonInitializer.h>

Inheritance diagram for Johansson::AgentInitializer:

Public Member Functions

 AgentInitializer ()
 Constructor. More...
 
 AgentInitializer (const AgentInitializer &init)
 Copy Constructor. More...
 
virtual ~AgentInitializer ()
 Destructor.
 
virtual bool setProperties (Agents::BaseAgent *agent)
 Sets the properties of the given agent based on the initializer's values. More...
 
virtual void setDefaults ()
 Sets all generators to default values. More...
 
virtual AgentInitializercopy () const
 Creates a copy of this AgentInitializer instance. More...
 

Protected Member Functions

virtual bool isRelevant (const ::std::string &tagName)
 Reports if this AgentInitializer cares about the given AgentSet property XML tag. More...
 
virtual
Agents::AgentInitializer::ParseResult 
setFromXMLAttribute (const ::std::string &paramName, const ::std::string &value)
 Defines a constant value for an agent property as specified by the attribute of an agent property tag. More...
 
virtual ParseResult processProperty (::std::string propName, TiXmlElement *node)
 Process the given <Property .../> tag. More...
 

Protected Attributes

FloatGenerator * _dirWeight
 The directional weight - repulsive force depends on direction to agent.
 

Detailed Description

Class which determines the agent properties for each new Johansson agent.

Constructor & Destructor Documentation

Johansson::AgentInitializer::AgentInitializer ( )

Constructor.

The values for each agent take a hard-coded default values.

Johansson::AgentInitializer::AgentInitializer ( const AgentInitializer init)

Copy Constructor.

Parameters
initThe initializer to copy values from

Member Function Documentation

virtual AgentInitializer* Johansson::AgentInitializer::copy ( ) const
inlinevirtual

Creates a copy of this AgentInitializer instance.

Returns
A pointer to a new AgentInitializer with all of the same values as this. The caller is responsible for freeing up the new instance.
bool Johansson::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 <Johansson> parameter set.

Parameters
tagNameThe tag to test for relevancy.
Returns
True if the tag is relevant, false otherwise.
AgentInitializer::ParseResult Johansson::AgentInitializer::processProperty ( ::std::string  propName,
TiXmlElement *  node 
)
protectedvirtual

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
propNameThe extractd "name" property from the Property tag.
nodeThe XML node for the Property tag.
Returns
True if parsing was "successful", false otherwise.
void Johansson::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.

Agents::AgentInitializer::ParseResult Johansson::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
paramNameA string containing the parameter name.
valueA string containing the value for the parameter.
Returns
The result of the parse: failure, ignored, or accepted.
bool Johansson::AgentInitializer::setProperties ( Agents::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 an+d then call the super class's setProperties function.

Parameters
agentThe agent whose properties are to be set.
Returns
True if the properties were set successfully, false otherwise.

The documentation for this class was generated from the following files: