Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Namespace Members | Class Members | File Members | Related Pages

Parser Class Reference

The parser for PotentialfieldComposition. More...

#include <PfcParser.h>

Collaboration diagram for Parser:

Collaboration graph
[legend]
List of all members.

Public Member Functions

 ~Parser ()
 Destructor.

void parse (PotentialfieldComposition *composition, std::string filename)
 Executes the parser.


Private Member Functions

std::string nextToken ()
 Returns the next token from file.

char nextChar ()
 Returns one character from file.

bool endOfFile ()
 Tests for the end of the file.

double parseAngle ()
 Parses an angle.

void parseComposition ()
 Parses parameters for PotentialfieldComposition.

ObjectparseObject ()
 Parses an object.

void parseAndInsertObject ()
 Parses an object and inserts it in the object list.

void parseObjectStateSymbol ()
 Parses an ObjectStateSymbol.

void parseInstanceGroup ()
 Parses a group of instances.

void parseInstance ()
 Parses the instance of an object.

void parseFormationObject ()
 Parses a formation object.

void parseSingleFormation (SingleFormation *&formation, const std::string &formationToken)
 Parses and creates single formation rule for a formation.

void parseMotionfield ()
 Parses a Motionfield.

void parseTransformation (PotentialfieldTransformation *&transformation, const std::string &typeToken)
 Parses and creates a transformation.

void parseAction (Action &action)
 Parses an Action for an Actionfield.

void parseActionfield ()
 Parses an Actionfield.

void parseFunction (PotentialfieldFunction *&function)
 Parses and creates a function.

void parseGeometricObject (PfieldGeometricObject *&geometricObject, const std::string &preparsedToken="")
 Parses and creates a geometric object.

void parseObjectsForField (const std::string &nameOfFirst, Potentialfield *field)
 Parses a list of object references.

void parseTimeConstraintsForField (Potentialfield *field)
 Parses some timing variables for a field.

void addGroupToField (const std::string &groupName, Potentialfield *field)
 Adds the elements of an object group to a field.

ObjectgetObject (const std::string &name)
 Finds an object given its name.

ObjectgetInstance (const std::string &name)
 Finds an object given its name and creates an instance.


Private Attributes

InBinaryFilefile
 A file object.

std::string currentToken
 The last parsed token.

std::vector< Object * > objects
 Parsed objects.

NameToIndexMap objectMap
 Fast mapping from name to index.

std::vector< InstanceGroupinstanceGroups
 The cached instance groups.

PotentialfieldCompositioncomposition
 The calling PotentialfieldComposition.


Detailed Description

The parser for PotentialfieldComposition.

Definition at line 56 of file PfcParser.h.


Constructor & Destructor Documentation

Parser::~Parser  ) 
 

Destructor.

Definition at line 63 of file PfcParser.cpp.

References instanceGroups.


Member Function Documentation

void Parser::parse PotentialfieldComposition composition,
std::string  filename
 

Executes the parser.

Parameters:
composition The calling PotentialfieldComposition
filename The file to open and parse

Definition at line 858 of file PfcParser.cpp.

References endOfFile(), nextToken(), parseActionfield(), parseAndInsertObject(), parseComposition(), parseFormationObject(), parseInstance(), parseInstanceGroup(), parseMotionfield(), and parseObjectStateSymbol().

Referenced by PotentialfieldComposition::load().

Here is the call graph for this function:

std::string Parser::nextToken  )  [private]
 

Returns the next token from file.

Returns:
A Token

Definition at line 97 of file PfcParser.cpp.

References endOfFile(), and nextChar().

Referenced by parse(), parseAction(), parseActionfield(), parseAngle(), parseComposition(), parseFormationObject(), parseFunction(), parseGeometricObject(), parseInstance(), parseInstanceGroup(), parseMotionfield(), parseObject(), parseObjectsForField(), parseObjectStateSymbol(), parseSingleFormation(), parseTimeConstraintsForField(), and parseTransformation().

Here is the call graph for this function:

char Parser::nextChar  )  [inline, private]
 

Returns one character from file.

Returns:
A character

Definition at line 75 of file PfcParser.cpp.

Referenced by nextToken().

bool Parser::endOfFile  )  [inline, private]
 

Tests for the end of the file.

Returns:
true, if the end of the file has been reached

Definition at line 87 of file PfcParser.cpp.

Referenced by nextToken(), and parse().

double Parser::parseAngle  )  [inline, private]
 

Parses an angle.

Returns:
The angle in radian

Definition at line 115 of file PfcParser.cpp.

References nextToken(), pi_180, and toDouble().

Referenced by parseInstance(), parseMotionfield(), parseObject(), parseSingleFormation(), and parseTransformation().

Here is the call graph for this function:

void Parser::parseComposition  )  [private]
 

Parses parameters for PotentialfieldComposition.

Definition at line 843 of file PfcParser.cpp.

References BEST_OF_N, composition, nextToken(), PotentialfieldComposition::setFieldSelectionParameters(), SUCCESSIVE_N_TIMES, and toInt().

Referenced by parse().

Here is the call graph for this function:

Object * Parser::parseObject  )  [private]
 

Parses an object.

Returns:
A pointer to the parsed object

Definition at line 317 of file PfcParser.cpp.

References ATTRACTIVE, CLOCKWISE, composition, COUNTER_CLOCKWISE, Sector::crossFunction, nextToken(), ObjectType, Sector::openingAngle, parseAngle(), parseFunction(), parseGeometricObject(), POINT_FIELD, REPULSIVE, SECTOR_FIELD, Object::setField(), Object::setFunction(), Object::setGeometry(), Object::setPfieldCompositionRef(), PotentialfieldFunction::setSmoothingParameters(), Object::setTangentialField(), SHAPE_FIELD, and toDouble().

Referenced by parseAndInsertObject(), and parseMotionfield().

Here is the call graph for this function:

void Parser::parseAndInsertObject  )  [private]
 

Parses an object and inserts it in the object list.

Definition at line 384 of file PfcParser.cpp.

References Object::getName(), objectMap, and parseObject().

Referenced by parse().

Here is the call graph for this function:

void Parser::parseObjectStateSymbol  )  [private]
 

Parses an ObjectStateSymbol.

Definition at line 293 of file PfcParser.cpp.

References PotentialfieldComposition::addDynamicObjectState(), composition, and nextToken().

Referenced by parse().

Here is the call graph for this function:

void Parser::parseInstanceGroup  )  [private]
 

Parses a group of instances.

Definition at line 300 of file PfcParser.cpp.

References getInstance(), instanceGroups, InstanceGroup::name, nextToken(), and InstanceGroup::objects.

Referenced by parse().

Here is the call graph for this function:

void Parser::parseInstance  )  [private]
 

Parses the instance of an object.

Definition at line 392 of file PfcParser.cpp.

References PotentialfieldComposition::addObject(), composition, PotentialfieldComposition::getIdFromObjectStateSymbol(), nextToken(), objectMap, parseAngle(), PfPose::pos, PfPose::rotation, Object::setActivation(), Object::setPose(), Object::setStatic(), toDouble(), PfVec::x, and PfVec::y.

Referenced by parse().

Here is the call graph for this function:

void Parser::parseFormationObject  )  [private]
 

Parses a formation object.

Definition at line 478 of file PfcParser.cpp.

References BestFitFormation::addFormation(), PotentialfieldComposition::addObject(), FormationObject::addSingleFormation(), composition, nextToken(), parseSingleFormation(), SELECT_MAX_GRADIENT, SELECT_MAX_PRIORITY, SELECT_MIN_DISTANCE, SELECT_MIN_GRADIENT, and BestFitFormation::setBestFitSelection().

Referenced by parse().

Here is the call graph for this function:

void Parser::parseSingleFormation SingleFormation *&  formation,
const std::string &  formationToken
[private]
 

Parses and creates single formation rule for a formation.

Parameters:
formation The single formation
formationToken Tehe first token to parse

Definition at line 423 of file PfcParser.cpp.

References ABSOLUTE_FORMATION, SingleFormation::addObject(), getInstance(), SingleFormation::init(), instanceGroups, nextToken(), parseAngle(), parseFunction(), RELATIVE_FORMATION, SingleFormation::setFunction(), RelativeFormation::setParameters(), SingleFormation::setPriority(), and toDouble().

Referenced by parseFormationObject().

Here is the call graph for this function:

void Parser::parseMotionfield  )  [private]
 

Parses a Motionfield.

Definition at line 551 of file PfcParser.cpp.

References Potentialfield::addCombinedField(), PotentialfieldComposition::addField(), Motionfield::addPathPlanner(), Motionfield::addRandomMotionGenerator(), CALLS, ChangeType, composition, CRITERION_CONST, CRITERION_GRADIENT, Motionfield::disableDegreesOfFreedom(), PotentialfieldAStarParameterSet::distanceToGoal, PotentialfieldAStarParameterSet::endOfFar, PotentialfieldAStarParameterSet::endOfNear, getInstance(), PotentialfieldAStarParameterSet::maxBranchingFactor, PotentialfieldAStarParameterSet::maxExpansionRadius, MILLISECONDS, PotentialfieldAStarParameterSet::minBranchingFactor, PotentialfieldAStarParameterSet::minExpansionRadius, nextToken(), PotentialfieldAStarParameterSet::numberOfCalls, parseAngle(), parseObject(), parseObjectsForField(), parseTimeConstraintsForField(), Motionfield::setAccelerationLimits(), Potentialfield::setCriterion(), PotentialfieldAStarParameterSet::stabilizationDistance, PotentialfieldAStarParameterSet::stabilizationObject, PotentialfieldAStarParameterSet::standardGradientLength, toBool(), toDouble(), toInt(), and PotentialfieldAStarParameterSet::useStabilization.

Referenced by parse().

Here is the call graph for this function:

void Parser::parseTransformation PotentialfieldTransformation *&  transformation,
const std::string &  typeToken
[private]
 

Parses and creates a transformation.

Parameters:
transformation The transformation
typeToken The first token (indicates the type)

Definition at line 635 of file PfcParser.cpp.

References Translation::alongGradient, Rotation::angle, getInstance(), Translation::maxGradientDeviation, Translation::maxLength, nextToken(), parseAngle(), Rotation::speed, Translation::speed, Translation::stepLength, PotentialfieldTransformation::time, toDouble(), Rotation::toGradient, Rotation::toObject, Translation::toObject, Translation::translation, PfVec::x, and PfVec::y.

Referenced by parseAction().

Here is the call graph for this function:

void Parser::parseAction Action action  )  [private]
 

Parses an Action for an Actionfield.

Parameters:
action The action

Definition at line 711 of file PfcParser.cpp.

References Action::actionType, getInstance(), Action::impactAreas, Action::joinAction, Action::manipulatedObject, MEASURE_OBJECT, MEASURE_SELF, MOVE_OBJECT, MOVE_SELF, nextToken(), parseGeometricObject(), parseTransformation(), PotentialfieldTransformation::probability, PotentialfieldTransformation::time, toBool(), toDouble(), and Action::transformations.

Referenced by parseActionfield().

Here is the call graph for this function:

void Parser::parseActionfield  )  [private]
 

Parses an Actionfield.

Definition at line 782 of file PfcParser.cpp.

References Actionfield::addAction(), Potentialfield::addCombinedField(), PotentialfieldComposition::addField(), BEST_SEQUENCE_FIELD, composition, CRITERION_ABSOLUTE, CRITERION_CONST, CRITERION_GAIN, CRITERION_GRADIENT, FIXED_SEQUENCE_FIELD, Action::name, nextToken(), parseAction(), parseObjectsForField(), parseTimeConstraintsForField(), Actionfield::setActionfieldType(), Actionfield::setConsiderTime(), Potentialfield::setCriterion(), SINGLE_ACTION_FIELD, toBool(), toDouble(), and toInt().

Referenced by parse().

Here is the call graph for this function:

void Parser::parseFunction PotentialfieldFunction *&  function  )  [private]
 

Parses and creates a function.

Parameters:
function The function to parse

Definition at line 179 of file PfcParser.cpp.

References nextToken(), PotentialfieldFunction::setSmoothingParameters(), and toDouble().

Referenced by parseObject(), and parseSingleFormation().

Here is the call graph for this function:

void Parser::parseGeometricObject PfieldGeometricObject *&  geometricObject,
const std::string &  preparsedToken = ""
[private]
 

Parses and creates a geometric object.

Parameters:
geometricObject A pointer to a geometric object
preparsedToken The first token to parse

Definition at line 121 of file PfcParser.cpp.

References Polygon::addPoint(), NoGeometry::initRadiusOfCollisionCircle(), Circle::initRadiusOfCollisionCircle(), Polygon::initRadiusOfCollisionCircle(), Line::initRadiusOfCollisionCircle(), PfieldGeometricObject::intersectable, Line, nextToken(), Line::p1, Line::p2, Circle::radius, toBool(), toDouble(), PfVec::x, and PfVec::y.

Referenced by parseAction(), and parseObject().

Here is the call graph for this function:

void Parser::parseObjectsForField const std::string &  nameOfFirst,
Potentialfield field
[private]
 

Parses a list of object references.

Parameters:
nameOfFirst The name of the first object
field The field to which the objects will be assigned

Definition at line 247 of file PfcParser.cpp.

References addGroupToField(), Potentialfield::addObject(), getInstance(), and nextToken().

Referenced by parseActionfield(), and parseMotionfield().

Here is the call graph for this function:

void Parser::parseTimeConstraintsForField Potentialfield field  )  [private]
 

Parses some timing variables for a field.

Parameters:
field The field

Definition at line 528 of file PfcParser.cpp.

References ChangeType, KEEP_FIELD, KEEP_RESULT, KeepType, nextToken(), Potentialfield::setTimeConstraints(), toChangeType(), and toInt().

Referenced by parseActionfield(), and parseMotionfield().

Here is the call graph for this function:

void Parser::addGroupToField const std::string &  groupName,
Potentialfield field
[private]
 

Adds the elements of an object group to a field.

Parameters:
groupName The name of the group
field The field to which the group is assigned

Definition at line 274 of file PfcParser.cpp.

References Potentialfield::addObject(), and instanceGroups.

Referenced by parseObjectsForField().

Here is the call graph for this function:

Object* Parser::getObject const std::string &  name  )  [private]
 

Finds an object given its name.

Parameters:
name The name
Returns:
A pointer to the object

Object * Parser::getInstance const std::string &  name  )  [inline, private]
 

Finds an object given its name and creates an instance.

Parameters:
name The name
Returns:
A pointer to the object

Definition at line 238 of file PfcParser.cpp.

References composition, PotentialfieldComposition::objectMap, and PotentialfieldComposition::objects.

Referenced by parseAction(), parseInstanceGroup(), parseMotionfield(), parseObjectsForField(), parseSingleFormation(), and parseTransformation().


Member Data Documentation

InBinaryFile* Parser::file [private]
 

A file object.

Definition at line 71 of file PfcParser.h.

std::string Parser::currentToken [private]
 

The last parsed token.

Definition at line 77 of file PfcParser.h.

std::vector<Object*> Parser::objects [private]
 

Parsed objects.

Definition at line 79 of file PfcParser.h.

NameToIndexMap Parser::objectMap [private]
 

Fast mapping from name to index.

Definition at line 81 of file PfcParser.h.

Referenced by parseAndInsertObject(), and parseInstance().

std::vector<InstanceGroup> Parser::instanceGroups [private]
 

The cached instance groups.

Definition at line 83 of file PfcParser.h.

Referenced by addGroupToField(), parseInstanceGroup(), parseSingleFormation(), and ~Parser().

PotentialfieldComposition* Parser::composition [private]
 

The calling PotentialfieldComposition.

Definition at line 85 of file PfcParser.h.

Referenced by getInstance(), parseActionfield(), parseComposition(), parseFormationObject(), parseInstance(), parseMotionfield(), parseObject(), and parseObjectStateSymbol().


The documentation for this class was generated from the following files:
Generated on Thu Sep 23 20:10:35 2004 for GT2004 by doxygen 1.3.6