ScriptRobot
|
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... |
|
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.
typedef enum ScriptRoutine::Type ScriptRoutine::Type |
ScriptRoutine::Type enum.
Determines the ScriptRoutine's type and what hook the routine will fetch from the module or engine.
enum ScriptRoutine::Type |
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@). |
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 | ( | ) |
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.
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.
i | the index of the hook to return. |
std::string ScriptRoutine::getHookDecl | ( | ) |
Retursn the hook deceleration as a string.
std::string ScriptRoutine::getName | ( | ) |
Returns the name of the ScriptRoutine.
unsigned int ScriptRoutine::getNumOfHooks | ( | ) |
Returns the number of hooks loaded in this ScriptRoutine.
unsigned int ScriptRoutine::getNumOfScripts | ( | ) |
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 "".
i | the index of the script to return. |
std::vector< std::string > ScriptRoutine::getScripts | ( | ) |
Returns the scripts of a ScriptRoutine.
ScriptRoutine::Type ScriptRoutine::getType | ( | ) |
Returns the ScriptRoutine type.
bool ScriptRoutine::hasScript | ( | std::string | script | ) |
Returns true if the ScriptRoutine has this script.
script | the name of the script to check. |
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.
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.
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.
name | the name of the ScriptRoutine. |
void ScriptRoutine::setScripts | ( | std::vector< std::string > | scripts | ) |
Sets the scripts vector.
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.
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.
name | the name of the ScriptRoutine. |
type | the ScriptRoutine type. |