ScriptRobot
 All Classes Functions Typedefs Enumerations Enumerator
ScriptRoutine Class Reference

ScriptRoutine class. More...

#include <ScriptRoutine.h>

Public Types

enum   Type {
  None = 0, Init = 1, Disabled = 2, Autonomous = 3,
  OperatorControl = 4, Test = 5
}
  ScriptRoutine::Type enum. More...
 
typedef enum ScriptRoutine::Type  Type
  ScriptRoutine::Type enum. More...
 

Public Member Functions

  ScriptRoutine ()
  ScriptRoutine constructor. More...
 
  ~ScriptRoutine ()
  ScriptRoutine destructor. More...
 
void  release ()
  Releases angelscript objects help by a Routine. More...
 
void  setup (std::string name, ScriptRoutine::Type type)
  Sets the name and type of a ScriptRoutine. More...
 
void  setScripts (std::vector< std::string > scripts)
  Sets the scripts vector. More...
 
void  loadHooksFromEngine (asIScriptEngine *engine)
  Loads all the hooks using an angelscript engine. More...
 
void  setName (std::string name)
  Sets the name of the ScriptRoutine. More...
 
std::string  getName ()
  Returns the name of the ScriptRoutine. More...
 
void  setType (ScriptRoutine::Type type)
  Sets the type of the ScriptRoutine. More...
 
ScriptRoutine::Type  getType ()
  Returns the ScriptRoutine type. More...
 
void  addScript (std::string script)
  Adds a script to the ScriptRoutine. More...
 
void  remScript (std::string script)
  Removes a script from the ScriptRoutine. More...
 
bool  hasScript (std::string script)
  Returns true if the ScriptRoutine has this script. More...
 
unsigned int  getNumOfScripts ()
  Returns the number of scripts in this ScriptRoutine. More...
 
std::string  getScript (unsigned int i)
  Returns a script by index. More...
 
std::vector< std::string >  getScripts ()
  Returns the scripts of a ScriptRoutine. More...
 
bool  addHookFromModule (asIScriptModule *module)
  Adds a hook using an angelscript module. More...
 
unsigned int  getNumOfHooks ()
  Returns the number of hooks loaded in this ScriptRoutine. More...
 
asIScriptFunction *  getHook (unsigned int i)
  Returns a hook by index. More...
 
std::string  getHookDecl ()
  Retursn the hook deceleration as a string. More...
 

Detailed Description

ScriptRoutine class.

The ScriptRoutine class fetches angelscript function pointers from script modules specified in the scripts vector. The hook that is fetched is specified by the ScriptRoutine type. the angelscript function pointers are then used to execute the robot code.

Member Typedef Documentation

ScriptRoutine::Type enum.

Determines the ScriptRoutine's type and what hook the routine will fetch from the module or engine.

Member Enumeration Documentation

ScriptRoutine::Type enum.

Determines the ScriptRoutine's type and what hook the routine will fetch from the module or engine.

Enumerator
None 

The ScriptRoutine has no type and will not fetch any hooks.

Init 

This is an Init ScriptRoutine. hook void onInit(Robot@).

Disabled 

This is a Disabled ScriptRoutine. hook: void onDisabled(Robot@).

Autonomous 

This is an Autonomous ScriptRoutine. hook: void onAutonomous(Robot@).

OperatorControl 

This is an OperatorControl ScriptRoutine. hook void onOperatorControl(Robot@).

Test 

This is a Test ScriptRoutine. hook void onTest(Robot@).

Constructor & Destructor Documentation

ScriptRoutine::ScriptRoutine ( )

ScriptRoutine constructor.

Creates an empty instance of a ScriptRoutine class with name set to "" and the type set to ScriptRoutine::None.

ScriptRoutine::~ScriptRoutine ( )

ScriptRoutine destructor.

calls release()

See Also
release()

Member Function Documentation

bool ScriptRoutine::addHookFromModule ( asIScriptModule *  module )

Adds a hook using an angelscript module.

If the name and type of the ScriptRoutine are not set this will return false. Checks if the module has been loaded with the name of a script this ScriptRoutine has. Then checks if the module has a hook of this ScriptRoutine's type.

void ScriptRoutine::addScript ( std::string  script )

Adds a script to the ScriptRoutine.

The script is added if the script is not already in the vector.

Parameters
script the name of the script to add.
asIScriptFunction * ScriptRoutine::getHook ( unsigned int  i )

Returns a hook by index.

If "i" exceeds getNumOfHooks() then the return will be NULL.

See Also
getNumOfHooks()
Parameters
i the index of the hook to return.
Returns
the angelscript function pointer at the index.
std::string ScriptRoutine::getHookDecl ( )

Retursn the hook deceleration as a string.

Returns
the hook deceleration as a string.
std::string ScriptRoutine::getName ( )

Returns the name of the ScriptRoutine.

Returns
the name of the ScriptRoutine.
unsigned int ScriptRoutine::getNumOfHooks ( )

Returns the number of hooks loaded in this ScriptRoutine.

Returns
the number of hooks loaded in this ScriptRoutine.
unsigned int ScriptRoutine::getNumOfScripts ( )

Returns the number of scripts in this ScriptRoutine.

Returns
the number of scripts in this ScriptRoutine.
std::string ScriptRoutine::getScript ( unsigned int  i )

Returns a script by index.

If "i" exceeds the getNumOfScripts() then the return will be "".

See Also
getNumOfScripts()
Parameters
i the index of the script to return.
Returns
the name of the script at the index.
std::vector< std::string > ScriptRoutine::getScripts ( )

Returns the scripts of a ScriptRoutine.

Returns
the scripts of a ScriptRoutine.
ScriptRoutine::Type ScriptRoutine::getType ( )

Returns the ScriptRoutine type.

Returns
the ScriptRoutine type.
bool ScriptRoutine::hasScript ( std::string  script )

Returns true if the ScriptRoutine has this script.

Parameters
script the name of the script to check.
Returns
true if the ScriptRoutine has this script.
void ScriptRoutine::loadHooksFromEngine ( asIScriptEngine *  engine )

Loads all the hooks using an angelscript engine.

If the name and type of the ScriptRoutine are not set this will return. Checks if a module has been loaded with the name of a script this ScriptRoutine has. Then checks if the module has a hook of this ScriptRoutine's type.

Parameters
engine an angelscript engine with all the scripts loaded.
void ScriptRoutine::release ( )

Releases angelscript objects help by a Routine.

Decreases the ref count of all stored angelscript function pointers.

void ScriptRoutine::remScript ( std::string  script )

Removes a script from the ScriptRoutine.

Parameters
script the name of the script to remove.
void ScriptRoutine::setName ( std::string  name )

Sets the name of the ScriptRoutine.

This can only be done if the name was not previously set.

Parameters
name the name of the ScriptRoutine.
void ScriptRoutine::setScripts ( std::vector< std::string >  scripts )

Sets the scripts vector.

Parameters
scripts the vector containing all scripts used by this ScriptRoutine.
void ScriptRoutine::setType ( ScriptRoutine::Type  type )

Sets the type of the ScriptRoutine.

This can only be done if the type was not previously set.

Parameters
type the ScriptRoutine type.
void ScriptRoutine::setup ( std::string  name,
ScriptRoutine::Type  type 
)

Sets the name and type of a ScriptRoutine.

This will only work if the name or type were not previously set.

Parameters
name the name of the ScriptRoutine.
type the ScriptRoutine type.

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