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

Xabsl2Engine Class Reference

Executes a behavior that was specified in the Xabsl language. More...

#include <Xabsl2Engine.h>

Inheritance diagram for Xabsl2Engine:

Inheritance graph
[legend]
Collaboration diagram for Xabsl2Engine:

Collaboration graph
[legend]
List of all members.

Public Member Functions

 Xabsl2Engine (Xabsl2ErrorHandler &e, unsigned long(*pTimeFunction)())
 Constructor.

 ~Xabsl2Engine ()
 Destructor.

void execute ()
 Executes the engine for the selected agent starting from the root option.

void executeSelectedBasicBehavior ()
 Executes only the selected basic behavior.

void createOptionGraph (Xabsl2InputSource &input)
 Reads the intermediate code from an input source and creates the option graph.

void registerBasicBehavior (Xabsl2BasicBehavior &basicBehavior)
 Registers a basic behavior at the engine.

bool setSelectedAgent (const char *name)
 Sets the selected Agent.

Debugging Interface
bool setRootOption (const char *name)
 Executes the option graph starting from a given option.

void setRootOption ()
 Sets the root option of the selected agent.

const Xabsl2OptiongetRootOption () const
 Returns the selected root option.

bool setOptionParameter (const char *name, const char *param, double value)
 Sets a parameter of a option.

bool setSelectedBasicBehavior (const char *name)
 Sets the selected basic behavior.

bool setBasicBehaviorParameter (const char *name, const char *param, double value)
 Sets a parameter of a basic behavior.

const char * getSelectedAgentName ()
 Returns the name of the selected agent.

const Xabsl2BasicBehaviorgetSelectedBasicBehavior ()
 Returns the selected basic behavior.


Private Member Functions

bool checkForLoops (Xabsl2Option *currenOptionPath[], int currentDepth)
 A recursive function that is used to check for loops in the option graph.


Private Attributes

Xabsl2Array< Xabsl2Agent * > agents
 The agents of the engine.

Xabsl2AgentselectedAgent
 The selected agent.

Xabsl2Array< Xabsl2Option * > options
 The options of the engine.

Xabsl2OptionrootOption
 The option where the execution of the option graph starts.

Xabsl2Array< Xabsl2BasicBehavior & > basicBehaviors
 The registered basic behaviors of the engine.

Xabsl2BasicBehaviorselectedBasicBehavior
 The selected basic behavior.

Xabsl2ErrorHandlererrorHandler
 Is invoked when there are problems during initialization.

bool initialized
 If true, the engine was successfully initialized.

unsigned long(* pTimeFunction )()
 A pointer to a function that returns the system time in ms.


Detailed Description

Executes a behavior that was specified in the Xabsl language.

Author:
Matthias Jüngel

Martin Lötzsch

Definition at line 22 of file Xabsl2Engine.h.


Constructor & Destructor Documentation

Xabsl2Engine::Xabsl2Engine Xabsl2ErrorHandler e,
unsigned long(*  pTimeFunction)()
 

Constructor.

Parameters:
e Is invoked when there are problems during initialization
pTimeFunction a pointer to a function that returns the system time in ms.

Definition at line 12 of file Xabsl2Engine.cpp.

References e.

Xabsl2Engine::~Xabsl2Engine  ) 
 

Destructor.

Definition at line 19 of file Xabsl2Engine.cpp.

References agents, Xabsl2Array< Xabsl2Agent * >::getSize(), Xabsl2Array< Xabsl2Option * >::getSize(), and options.

Here is the call graph for this function:


Member Function Documentation

void Xabsl2Engine::execute  ) 
 

Executes the engine for the selected agent starting from the root option.

(Including the selected basic behavior)

Definition at line 30 of file Xabsl2Engine.cpp.

References Xabsl2Option::activeState, Xabsl2Option::execute(), executeSelectedBasicBehavior(), Xabsl2Array< Xabsl2Option * >::getSize(), Xabsl2Option::optionIsActive, options, Xabsl2Option::optionWasActive, selectedBasicBehavior, Xabsl2Symbols::setOutputSymbols(), Xabsl2State::subsequentBasicBehavior, and Xabsl2State::subsequentOption.

Referenced by GTXabsl2EngineExecutor::executeEngine().

Here is the call graph for this function:

void Xabsl2Engine::executeSelectedBasicBehavior  ) 
 

Executes only the selected basic behavior.

Definition at line 60 of file Xabsl2Engine.cpp.

References basicBehaviors, Xabsl2BasicBehavior::basicBehaviorWasActiveDuringLastExecutionOfEngine, Xabsl2BasicBehavior::execute(), Xabsl2Array< Xabsl2BasicBehavior & >::getSize(), and selectedBasicBehavior.

Referenced by execute(), and GTXabsl2EngineExecutor::executeEngine().

Here is the call graph for this function:

void Xabsl2Engine::createOptionGraph Xabsl2InputSource input  ) 
 

Reads the intermediate code from an input source and creates the option graph.

Note that the basic behaviors and symbols have to be registered before that function is called.

Definition at line 73 of file Xabsl2Engine.cpp.

References agents, Xabsl2Array< Xabsl2Agent * >::append(), Xabsl2Array< Xabsl2Option * >::append(), basicBehaviors, checkForLoops(), Xabsl2InputSource::close(), Xabsl2ErrorHandler::error(), Xabsl2ErrorHandler::errorsOccurred, Xabsl2Array< Xabsl2Option * >::getElement(), Xabsl2Agent::getRootOption(), Xabsl2Array< Xabsl2Agent * >::getSize(), Xabsl2ErrorHandler::message(), Xabsl2NamedItem::n, Xabsl2InputSource::open(), options, Xabsl2InputSource::readString(), Xabsl2InputSource::readValue(), selectedAgent, selectedBasicBehavior, and XABSL2_DEBUG_INIT.

Referenced by GTXabsl2EngineExecutor::init().

Here is the call graph for this function:

void Xabsl2Engine::registerBasicBehavior Xabsl2BasicBehavior basicBehavior  ) 
 

Registers a basic behavior at the engine.

This must be done before the intermediate code is read.

Parameters:
basicBehavior A reference to the basic behavior

Definition at line 185 of file Xabsl2Engine.cpp.

References Xabsl2Array< Xabsl2BasicBehavior & >::append(), basicBehaviors, Xabsl2ErrorHandler::error(), Xabsl2Array< Xabsl2BasicBehavior & >::exists(), Xabsl2ErrorHandler::message(), Xabsl2NamedItem::n, and XABSL2_DEBUG_INIT.

Referenced by GT2004HeadControlBasicBehaviors::registerBasicBehaviors(), GT2004SimpleBasicBehaviors::registerBasicBehaviors(), GT2004PotentialFieldBasicBehaviors::registerBasicBehaviors(), GT2004EvolutionBasicBehaviors::registerBasicBehaviors(), and CommonBasicBehaviors::registerBasicBehaviors().

Here is the call graph for this function:

bool Xabsl2Engine::setSelectedAgent const char *  name  ) 
 

Sets the selected Agent.

If the last selected agent was different from the new one, the root option is changed depending on the new agent.

Parameters:
name The name of the agent
Returns:
if the requested agent exists

Definition at line 273 of file Xabsl2Engine.cpp.

References agents, Xabsl2Array< Xabsl2Agent * >::exists(), Xabsl2Array< Xabsl2Agent * >::getElement(), Xabsl2Agent::getRootOption(), and selectedAgent.

Referenced by GTXabsl2EngineExecutor::setSelectedAgent().

Here is the call graph for this function:

bool Xabsl2Engine::checkForLoops Xabsl2Option currenOptionPath[],
int  currentDepth
[private]
 

A recursive function that is used to check for loops in the option graph.

Parameters:
currenOptionPath An array of the currently traced option path
currentDepth The depth of the current option path
Returns:
If true, then a loop was detected.

Definition at line 146 of file Xabsl2Engine.cpp.

References Xabsl2ErrorHandler::error(), Xabsl2Array< Xabsl2State * >::getSize(), Xabsl2NamedItem::n, and Xabsl2Option::states.

Referenced by createOptionGraph().

Here is the call graph for this function:

bool Xabsl2Engine::setRootOption const char *  name  ) 
 

Executes the option graph starting from a given option.

Can be called to test a single option.

Parameters:
name The name of the option
Returns:
When false, the option is not known to the engine

Definition at line 208 of file Xabsl2Engine.cpp.

References Xabsl2Array< Xabsl2Option * >::exists(), Xabsl2Array< Xabsl2Option * >::getElement(), and options.

Referenced by GTXabsl2EngineExecutor::executeEngine(), and GTXabsl2EngineExecutor::handleMessage().

Here is the call graph for this function:

void Xabsl2Engine::setRootOption  ) 
 

Sets the root option of the selected agent.

Definition at line 219 of file Xabsl2Engine.cpp.

References Xabsl2Agent::getRootOption(), and selectedAgent.

Here is the call graph for this function:

const Xabsl2Option * Xabsl2Engine::getRootOption  )  const
 

Returns the selected root option.

Definition at line 224 of file Xabsl2Engine.cpp.

Referenced by GTXabsl2Profiler::doProfiling(), GTXabsl2Profiler::init(), and GTXabsl2EngineExecutor::sendDebugMessage().

bool Xabsl2Engine::setOptionParameter const char *  name,
const char *  param,
double  value
 

Sets a parameter of a option.

Parameters:
name The name of the option
param The name of of the parameter
value The value for the parameter
Returns:
When false, the option or the parameter does not exist

Definition at line 246 of file Xabsl2Engine.cpp.

References Xabsl2Array< double >::exists(), Xabsl2Array< Xabsl2Option * >::exists(), Xabsl2Array< Xabsl2Option * >::getElement(), options, Xabsl2Option::parameters, and Xabsl2Array< double >::setElement().

Referenced by GTXabsl2EngineExecutor::handleMessage().

Here is the call graph for this function:

bool Xabsl2Engine::setSelectedBasicBehavior const char *  name  ) 
 

Sets the selected basic behavior.

Can be called to test a single basic behavior.

Parameters:
name The name of the basic behavior.
Returns:
When false, the basic behavior was not registered

Definition at line 197 of file Xabsl2Engine.cpp.

References basicBehaviors, Xabsl2Array< Xabsl2BasicBehavior & >::exists(), Xabsl2Array< Xabsl2BasicBehavior & >::getElement(), and selectedBasicBehavior.

Referenced by GTXabsl2EngineExecutor::handleMessage().

Here is the call graph for this function:

bool Xabsl2Engine::setBasicBehaviorParameter const char *  name,
const char *  param,
double  value
 

Sets a parameter of a basic behavior.

Parameters:
name The name of the basic behavior
param The name of of the parameter
value The value for the parameter
Returns:
When false, the basic behavior or the parameter were not registered

Definition at line 229 of file Xabsl2Engine.cpp.

References basicBehaviors, Xabsl2Array< double & >::exists(), Xabsl2Array< Xabsl2BasicBehavior & >::exists(), Xabsl2Array< Xabsl2BasicBehavior & >::getElement(), Xabsl2BasicBehavior::parameters, and Xabsl2Array< double & >::setElement().

Referenced by GTXabsl2EngineExecutor::handleMessage().

Here is the call graph for this function:

const char * Xabsl2Engine::getSelectedAgentName  ) 
 

Returns the name of the selected agent.

Definition at line 263 of file Xabsl2Engine.cpp.

References Xabsl2NamedItem::n, and selectedAgent.

Referenced by GTXabsl2EngineExecutor::sendDebugMessage().

const Xabsl2BasicBehavior * Xabsl2Engine::getSelectedBasicBehavior  ) 
 

Returns the selected basic behavior.

Definition at line 268 of file Xabsl2Engine.cpp.

References selectedBasicBehavior.

Referenced by GTXabsl2EngineExecutor::sendDebugMessage().


Member Data Documentation

Xabsl2Array<Xabsl2Agent*> Xabsl2Engine::agents [private]
 

The agents of the engine.

Definition at line 69 of file Xabsl2Engine.h.

Referenced by createOptionGraph(), setSelectedAgent(), and ~Xabsl2Engine().

Xabsl2Agent* Xabsl2Engine::selectedAgent [private]
 

The selected agent.

Definition at line 72 of file Xabsl2Engine.h.

Referenced by createOptionGraph(), getSelectedAgentName(), setRootOption(), and setSelectedAgent().

Xabsl2Array<Xabsl2Option*> Xabsl2Engine::options [private]
 

The options of the engine.

Definition at line 75 of file Xabsl2Engine.h.

Referenced by createOptionGraph(), execute(), setOptionParameter(), setRootOption(), and ~Xabsl2Engine().

Xabsl2Option* Xabsl2Engine::rootOption [private]
 

The option where the execution of the option graph starts.

Definition at line 78 of file Xabsl2Engine.h.

Xabsl2Array<Xabsl2BasicBehavior&> Xabsl2Engine::basicBehaviors [private]
 

The registered basic behaviors of the engine.

Definition at line 81 of file Xabsl2Engine.h.

Referenced by createOptionGraph(), executeSelectedBasicBehavior(), registerBasicBehavior(), setBasicBehaviorParameter(), and setSelectedBasicBehavior().

Xabsl2BasicBehavior* Xabsl2Engine::selectedBasicBehavior [private]
 

The selected basic behavior.

Definition at line 84 of file Xabsl2Engine.h.

Referenced by createOptionGraph(), execute(), executeSelectedBasicBehavior(), getSelectedBasicBehavior(), and setSelectedBasicBehavior().

Xabsl2ErrorHandler& Xabsl2Engine::errorHandler [private]
 

Is invoked when there are problems during initialization.

Reimplemented from Xabsl2Symbols.

Definition at line 87 of file Xabsl2Engine.h.

bool Xabsl2Engine::initialized [private]
 

If true, the engine was successfully initialized.

Definition at line 98 of file Xabsl2Engine.h.

unsigned long(* Xabsl2Engine::pTimeFunction)() [private]
 

A pointer to a function that returns the system time in ms.


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