|
ScriptRobot
|
ScriptPackage class. More...
#include <ScriptPackage.h>
Public Types |
|
| enum | Error
{ NoError = 0, NotLoaded = -1, NotBuilt = -2, EngineIsNull = -3, CouldNotOpenFile = -4, NotAScriptPackage = -5, ErrorParsingConfig = -6, MissingProjectConfig = -7, MissingRobotConfig = -8, CouldNotRegisterProperty = -10, CouldNotBuildScript = -9 } |
| Error enum. More... |
|
| typedef enum ScriptPackage::Error | Error |
| Error enum. More... |
|
Public Member Functions |
|
| ScriptPackage () | |
| ScriptPackage constructor. More... |
|
| ~ScriptPackage () | |
| ScriptPackage destructor calls
unload() on the ScriptPackage releasing all angelscript
objects created by the ScriptPackage. More... |
|
| ScriptPackage::Error | getLastError () |
| Returns the last error set. More... |
|
| std::string | getLastErrorMessage () |
| Returns the last error message set. More... |
|
| bool | isValid () |
| Returns true if a ScriptPackage is ready for use. More... |
|
| ScriptPackage::Error | load (std::string path) |
| Loads a ScriptPackage from the path. More... |
|
| void | unload () |
| Unloads a ScriptPackage from memory. More... |
|
| ScriptPackage::Error | build (asIScriptEngine *engine) |
| Builds a ScriptPackage. More... |
|
| void | release () |
| Releases all angelscript objects. More... |
|
| ScriptPackage::Error | write (std::string path) |
| Writes the ScriptPackage to a file. More... |
|
| std::string | getPath () |
| Returns the last set path. More... |
|
| std::string | getProjectConfig () |
| Returns the project config file as a string.
More... |
|
| std::string | getRobotConfig () |
| Returns the robot config file as a string.
More... |
|
| void | addSection (std::string name, std::string file) |
| Adds a section to a ScriptPackage. More... |
|
| void | remSection (std::string name) |
| Removes a section from a ScriptPackage. More... |
|
| PackageSection * | getSection (std::string name) |
| Returns a section. More... |
|
| void | addRoutine (std::string name, ScriptRoutine::Type type, std::vector< std::string > scripts) |
| Adds a routine to a ScriptPakcage. More... |
|
| void | remRoutine (std::string name) |
| Removes a routine from a ScriptPackage. More... |
|
| ScriptRoutine * | getRoutine (std::string name) |
| Returns a routine. More... |
|
| ScriptRoutine * | getInitRoutine () |
| Returns the init routine. More... |
|
| std::string | getDefaultDisabledRoutine () |
| Returns the default disabled routine. More... |
|
| std::string | getDefaultAutonomousRoutine () |
| Returns the default autonomous routine.
More... |
|
| std::string | getOperatorControlRoutine () |
| Returns the default operator control routine.
More... |
|
| std::string | getTestRoutine () |
| Returns the default test routine. More... |
|
| void | addProperty (std::string definition, std::string type, std::string name, void *ptr) |
| Adds a property to a ScriptPakcage. More... |
|
| void | remProperty (std::string name) |
| Removes a property from a ScriptPackage. More... |
|
| GlobalProperty * | getProperty (std::string name) |
| Returns a property. More... |
|
Static Public Member Functions |
|
| static std::string | addExstension (std::string path) |
| Adds .scpkg to the end of the file path if
isn't already there. More... |
|
| static bool | isScript (std::string name) |
| Returns true if the file name ends in .as.
More... |
|
| static bool | isConfig (std::string name) |
| Returns true if the file name ends in .cfg.
More... |
|
ScriptPackage class.
The ScriptPackage class loads and writes ScriptPackage files (.scpkg) A ScriptPackage file is a binary file that archives scripts and configs. Into PackageSections containing the file and original file path. The ScriptPackage once successfully loaded is configured and built using a project.cfg and a robot.cfg. robot.cfg contains info about the robots devices and their ports and the project.cfg contains info about ScriptRoutines for the robot to execute. TODO: make this more consice
| typedef enum ScriptPackage::Error ScriptPackage::Error |
Error enum.
Used to characterize the an error caused while calling load, unload, build, release or write.
| enum ScriptPackage::Error |
Error enum.
Used to characterize the an error caused while calling load, unload, build, release or write.
| Enumerator | |
|---|---|
| NoError |
The ScriptPackage is ready for use. |
| NotLoaded |
The ScriptPackage hasn't been loaded yet. |
| NotBuilt |
The ScriptPackage hasn't been built yet. |
| EngineIsNull |
The Engine used to build was null. |
| CouldNotOpenFile |
A file path couldn't be opened. |
| NotAScriptPackage |
The file loaded wasn't a ScriptPackage. |
| ErrorParsingConfig |
There was an error while parsing a config. |
| MissingProjectConfig |
project.cfg is missing. |
| MissingRobotConfig |
robot.cfg is missing. |
| CouldNotRegisterProperty |
There was an error while registering a property. |
| CouldNotBuildScript |
There was an error while building a script. |
| ScriptPackage::ScriptPackage | ( | ) |
ScriptPackage constructor.
Creates an empty instance of a ScriptPackage class with the angelscript engine set to NULL.
| ScriptPackage::~ScriptPackage | ( | ) |
ScriptPackage destructor calls unload() on the ScriptPackage releasing all angelscript objects created by the ScriptPackage.
|
static |
Adds .scpkg to the end of the file path if isn't already there.
| path | a path. |
| void ScriptPackage::addProperty | ( | std::string | definition, |
| std::string | type, | ||
| std::string | name, | ||
| void * | ptr | ||
| ) |
Adds a property to a ScriptPakcage.
If the property already existed it is overwritten.
| definition | the line used to generate the property from a config. |
| type | the property type as used in angelscript. |
| name | the name of the property as to be used in angelscript code. |
| ptr | the pointer to the property. |
| void ScriptPackage::addRoutine | ( | std::string | name, |
| ScriptRoutine::Type | type, | ||
| std::vector< std::string > | scripts | ||
| ) |
Adds a routine to a ScriptPakcage.
If the routine already existed it is overwritten.
| name | the name of the routine. |
| type | the routine type. |
| scripts | the scripts utilized by the routine. |
| void ScriptPackage::addSection | ( | std::string | name, |
| std::string | file | ||
| ) |
Adds a section to a ScriptPackage.
If the section already existed it is overwritten.
| name | the file name of section. |
| file | the file as a string. |
| ScriptPackage::Error ScriptPackage::build | ( | asIScriptEngine * | engine | ) |
Builds a ScriptPackage.
Registers all GlobalProperties. And Builds all scripts. Then fetches all hooks for ScriptRoutines. If building was not successful release() is called on the ScriptPackage.
| engine | a fully registered angelscript engine. |
| std::string ScriptPackage::getDefaultAutonomousRoutine | ( | ) |
Returns the default autonomous routine.
| std::string ScriptPackage::getDefaultDisabledRoutine | ( | ) |
Returns the default disabled routine.
| ScriptRoutine * ScriptPackage::getInitRoutine | ( | ) |
Returns the init routine.
| ScriptPackage::Error ScriptPackage::getLastError | ( | ) |
Returns the last error set.
| std::string ScriptPackage::getLastErrorMessage | ( | ) |
Returns the last error message set.
| std::string ScriptPackage::getOperatorControlRoutine | ( | ) |
Returns the default operator control routine.
| std::string ScriptPackage::getPath | ( | ) |
Returns the last set path.
The path is set when write or load is called.
| std::string ScriptPackage::getProjectConfig | ( | ) |
Returns the project config file as a string.
| GlobalProperty * ScriptPackage::getProperty | ( | std::string | name | ) |
Returns a property.
| name | the name of the property to fetch. |
| std::string ScriptPackage::getRobotConfig | ( | ) |
Returns the robot config file as a string.
| ScriptRoutine * ScriptPackage::getRoutine | ( | std::string | name | ) |
Returns a routine.
| name | the name of the routine to fetch. |
| PackageSection * ScriptPackage::getSection | ( | std::string | name | ) |
Returns a section.
| name | the name of the section to fetch. |
| std::string ScriptPackage::getTestRoutine | ( | ) |
Returns the default test routine.
|
static |
Returns true if the file name ends in .cfg.
| name | the name of a file to test. |
|
static |
Returns true if the file name ends in .as.
| param | the name of a file to test. |
| bool ScriptPackage::isValid | ( | ) |
Returns true if a ScriptPackage is ready for use.
The ScriptPackage will only be valid if it has been loaded and built successfully.
| ScriptPackage::Error ScriptPackage::load | ( | std::string | path | ) |
Loads a ScriptPackage from the path.
Loads a .scpkg file into memory and prepares the ScriptPackage to be built. If the ScriptPackage is unsuccessfully loaded unload() is called on it.
| path | the full path to a .scpkg file. |
| void ScriptPackage::release | ( | ) |
Releases all angelscript objects.
All angelscript objects owned by the ScriptPackage will be released. The ScriptPackage will no longer be valid if it previously was.
| void ScriptPackage::remProperty | ( | std::string | name | ) |
Removes a property from a ScriptPackage.
The ScriptPackage will no longer be valid if it previously was.
| name | the name of the property to remove. |
| void ScriptPackage::remRoutine | ( | std::string | name | ) |
Removes a routine from a ScriptPackage.
The ScriptPackage will no longer be valid if it previously was.
| name | the name of the routine to remove. |
| void ScriptPackage::remSection | ( | std::string | name | ) |
Removes a section from a ScriptPackage.
The ScriptPackage will no longer be valid if it previously was.
| name | the name of the section to remove. |
| void ScriptPackage::unload | ( | ) |
Unloads a ScriptPackage from memory.
Calls release() on the ScriptPackage releasing all angelscript objects created by the ScriptPackage. The ScriptPackage will no longer be valid if it previously was.
| ScriptPackage::Error ScriptPackage::write | ( | std::string | path | ) |
Writes the ScriptPackage to a file.
Only writes objects created using add functions.
| path | the full path to a .scpkg file. |