ScriptingAccess Class Reference

#include <rtt/ScriptingAccess.hpp>

Inheritance diagram for ScriptingAccess:

Inheritance graph
[legend]
List of all members.

Detailed Description

This interface allows to load program scripts and state machines and allows execution of code.

It can be found as the scripting object of a TaskContext.


Public Types

typedef std::vector< ProgramInterfacePtr > Functions
 List of executed functions.

Public Member Functions

 ScriptingAccess (TaskContext *parent)
virtual int execute (const std::string &code)
 Parse and execute a statement.
virtual CommandC getCommand (int ticket)
 Get the associated command with a given ticket number.
virtual Functions loadFunctions (std::string filename, bool do_throw=false)
 Load and execute a set of functions into the Program Processor for execution.
virtual Functions loadFunctions (std::string code, std::string filename, bool do_throw=false)
 Load and execute a set of functions into the Program Processor for execution.
virtual bool loadPrograms (std::string filename, bool do_throw=false)
 Load a set of programs into the Program Processor for execution.
virtual bool loadPrograms (std::string code, std::string filename, bool do_throw=false)
 Load a set of programs into the Program Processor for execution.
virtual bool unloadProgram (std::string name, bool do_throw=false)
 Unload a program from the Program Processor.
virtual std::vector< std::string > getPrograms () const
 Get a list of the loaded programs.
virtual bool hasProgram (std::string name) const
 Check if a program was loaded.
virtual int getProgramLine (std::string name) const
 Get the current line of execution of a loaded program script.
virtual std::string getProgramText (std::string name) const
 Get the original script description of a loaded program.
virtual std::string getProgramStatus (std::string name) const
 Get the status of the program in a human readable form.
virtual bool loadStateMachines (std::string filename, bool do_throw=false)
 Load a set of state machines into the StateMachineProcessor for execution.
virtual bool loadStateMachines (std::string code, std::string filename, bool do_throw=false)
 Load a set of state machines into the StateMachineProcessor for execution.
virtual bool unloadStateMachine (std::string name, bool do_throw=false)
 Unload a state machine from the StateMachineProcessor.
virtual bool hasStateMachine (std::string name) const
 Check if a state machine was loaded.
virtual std::vector< std::string > getStateMachines () const
 Get a list of the loaded state machines.
virtual std::string getStateMachineText (std::string name) const
 Get the original script description of a loaded state machine.
virtual std::string getStateMachineStatus (std::string name) const
 Get the status of the state machine in a human readable form.
virtual int getStateMachineLine (std::string name) const
 Get the current line of execution of a loaded state machine script.
virtual std::string getCurrentState (std::string name) const
 Get the current state of an activated state machine.

Protected Attributes

TaskContextmparent


Member Function Documentation

virtual int execute ( const std::string &  code  )  [virtual]

Parse and execute a statement.

Parameters:
code A single statement to execute.
Returns:
A ticket number.
Return values:
-1 if the code could not be parsed.
0 if the code was an expression and could be executed.
>0 if the code was a command and is being executed.
See also:
getCommand

Reimplemented in ScriptingAccessProxy, and ParserScriptingAccess.

virtual CommandC getCommand ( int  ticket  )  [virtual]

Get the associated command with a given ticket number.

Parameters:
ticket The ticket number returned by execute().
Returns:
An object which represents the command.

Reimplemented in ScriptingAccessProxy, and ParserScriptingAccess.

virtual Functions loadFunctions ( std::string  filename,
bool  do_throw = false 
) [virtual]

Load and execute a set of functions into the Program Processor for execution.

Parameters:
filename The file to load
do_throw Set to yes to cause the parse errors to be thrown instead of being printed to the Logger interface.
Returns:
A list of functions loaded in the ProgramProcessor.

Reimplemented in ParserScriptingAccess.

virtual Functions loadFunctions ( std::string  code,
std::string  filename,
bool  do_throw = false 
) [virtual]

Load and execute a set of functions into the Program Processor for execution.

Parameters:
code A string containing the function definitions.
filename The file name to use in the error messages.
do_throw Set to yes to cause the parse errors to be thrown instead of being printed to the Logger interface.
Returns:
A list of functions loaded in the ProgramProcessor.

Reimplemented in ParserScriptingAccess.

virtual bool loadPrograms ( std::string  filename,
bool  do_throw = false 
) [virtual]

Load a set of programs into the Program Processor for execution.

The programs are just loaded, not started yet.

Parameters:
filename The file to load
do_throw Set to yes to cause the parse errors to be thrown instead of being printed to the Logger interface.
Returns:
true if all state machines could be loaded in the ProgramProcessor.

Reimplemented in ParserScriptingAccess.

virtual bool loadPrograms ( std::string  code,
std::string  filename,
bool  do_throw = false 
) [virtual]

Load a set of programs into the Program Processor for execution.

The programs are just loaded, not started yet.

Parameters:
code A string containing the function definitions.
filename The file name to use in the error messages.
do_throw Set to yes to cause the parse errors to be thrown instead of being printed to the Logger interface.
Returns:
true if all state machines could be loaded in the ProgramProcessor.

Reimplemented in ScriptingAccessProxy, and ParserScriptingAccess.

virtual bool unloadProgram ( std::string  name,
bool  do_throw = false 
) [virtual]

Unload a program from the Program Processor.

Parameters:
name The name of the loaded program.
do_throw Set to yes to cause the unloading errors to be thrown instead of being printed to the Logger interface.
Returns:
true if it could be unloaded

Reimplemented in ScriptingAccessProxy, and ParserScriptingAccess.

virtual std::vector<std::string> getPrograms (  )  const [virtual]

Get a list of the loaded programs.

Returns:
A list of program names.

Reimplemented in ScriptingAccessProxy.

virtual bool hasProgram ( std::string  name  )  const [virtual]

Check if a program was loaded.

Parameters:
name The name of the program.
Returns:
True if so.

Reimplemented in ScriptingAccessProxy.

virtual int getProgramLine ( std::string  name  )  const [virtual]

Get the current line of execution of a loaded program script.

Parameters:
name The name of the program.
Returns:
The line number.
Return values:
-1 if the program does not exist.
0 if the program is not running.
n the line number if the program is executing.

Reimplemented in ScriptingAccessProxy.

virtual std::string getProgramText ( std::string  name  )  const [virtual]

Get the original script description of a loaded program.

Parameters:
name The name of the program.
Returns:
A string containing only that program.

Reimplemented in ScriptingAccessProxy.

virtual std::string getProgramStatus ( std::string  name  )  const [virtual]

Get the status of the program in a human readable form.

Parameters:
name The name of the program.
Returns:
The ProgramInterface::Status as a string.

Reimplemented in ScriptingAccessProxy.

virtual bool loadStateMachines ( std::string  filename,
bool  do_throw = false 
) [virtual]

Load a set of state machines into the StateMachineProcessor for execution.

The state machines are just loaded, not started yet.

Parameters:
filename The file to load
do_throw Set to yes to cause the parse errors to be thrown instead of being printed to the Logger interface.
Returns:
true if all state machines could be loaded in the StateMachineProcessor.

Reimplemented in ParserScriptingAccess.

virtual bool loadStateMachines ( std::string  code,
std::string  filename,
bool  do_throw = false 
) [virtual]

Load a set of state machines into the StateMachineProcessor for execution.

The state machines are just loaded, not started yet.

Parameters:
code A string containing the function definitions.
filename The file name to use in the error messages.
do_throw Set to yes to cause the parse errors to be thrown instead of being printed to the Logger interface.
Returns:
true if all state machines could be loaded in the StateMachineProcessor.

Reimplemented in ScriptingAccessProxy, and ParserScriptingAccess.

virtual bool unloadStateMachine ( std::string  name,
bool  do_throw = false 
) [virtual]

Unload a state machine from the StateMachineProcessor.

Parameters:
name The name of the loaded program.
do_throw Set to yes to cause the unloading errors to be thrown instead of being printed to the Logger interface.
Returns:
true if it could be unloaded

Reimplemented in ScriptingAccessProxy, and ParserScriptingAccess.

virtual bool hasStateMachine ( std::string  name  )  const [virtual]

Check if a state machine was loaded.

Parameters:
name The name of the state machine.
Returns:
True if so.

Reimplemented in ScriptingAccessProxy.

virtual std::vector<std::string> getStateMachines (  )  const [virtual]

Get a list of the loaded state machines.

Returns:
A list of state machine names.

Reimplemented in ScriptingAccessProxy.

virtual std::string getStateMachineText ( std::string  name  )  const [virtual]

Get the original script description of a loaded state machine.

Parameters:
name The name of the state machine.
Returns:
A string containing only that state machine.

Reimplemented in ScriptingAccessProxy.

virtual std::string getStateMachineStatus ( std::string  name  )  const [virtual]

Get the status of the state machine in a human readable form.

Parameters:
name The name of the state machine.
Returns:
The State MachineInterface::Status as a string.

Reimplemented in ScriptingAccessProxy.

virtual int getStateMachineLine ( std::string  name  )  const [virtual]

Get the current line of execution of a loaded state machine script.

Parameters:
name The name of the state machine.
Returns:
The line number.
Return values:
-1 if the state machine does not exist.
0 if the state machine is not running.
n the line number if the state machine is executing.

Reimplemented in ScriptingAccessProxy.

virtual std::string getCurrentState ( std::string  name  )  const [virtual]

Get the current state of an activated state machine.

Parameters:
name The name of the state machine
Returns:
The current state.

Reimplemented in ScriptingAccessProxy.


The documentation for this class was generated from the following file:
Generated on Fri May 11 11:19:45 2007 for Orocos by  doxygen 1.5.1