Orocos Real-Time Toolkit
2.6.0
|
This class represents a function. More...
#include <rtt/scripting/FunctionGraph.hpp>
Public Types | |
typedef EdgeCondition::EdgeProperty | EdgeProperty |
typedef VertexNode::VertProperty | VertProperty |
typedef boost::adjacency_list < boost::vecS, boost::listS, boost::directedS, VertProperty, EdgeProperty > | Graph |
typedef boost::graph_traits < Graph >::vertex_descriptor | Vertex |
typedef boost::graph_traits < Graph >::edge_descriptor | Edge |
Public Member Functions | |
FunctionGraph (const std::string &name, bool unload_on_stop) | |
Create a FunctionGraph with a given name. | |
FunctionGraph (const FunctionGraph &orig) | |
Copy a FunctionGraph. | |
void | setProgramService (ServicePtr myservice) |
Set a service that manages this script. | |
void | setUnloadOnStop (bool unload_on_stop) |
Sets the unloading policy on stop or error. | |
virtual bool | needsStart () const |
Returns true if a start() is necessary when this function is loaded with ExecutionEngine::runFunction(). | |
void | finish () |
To be called after a function is constructed. | |
virtual bool | start () |
Start the execution of this program. | |
virtual bool | execute () |
Execute as much actions until the program needs to wait on a condition to become true. | |
virtual void | loading () |
Informs this object that it got loaded in an ExecutionEngine. | |
virtual void | unloading () |
Informs this object that it got unloaded from an ExecutionEngine. | |
virtual bool | stop () |
Stop the execution of this program. | |
virtual bool | pause () |
Pause or start-and-pause the execution of this program. | |
virtual bool | step () |
Execute a single action when paused. | |
virtual bool | stepDone () const |
virtual void | reset () |
Identical to stop();. | |
virtual int | getLineNumber () const |
Return the current 'line number' of the program. | |
virtual const std::string & | getName () const |
Programs can be refered to by name. | |
virtual FunctionGraph * | copy (std::map< const base::DataSourceBase *, base::DataSourceBase * > &replacementdss) const |
Clone this Program. | |
virtual FunctionGraph * | clone () const |
void | setName (const std::string &_name) |
Set the name of this program. | |
void | setText (const std::string &t) |
Set the program text. | |
std::string | getText () const |
Return the program text to which getLineNumber() refers. | |
void | debugPrintout () const |
Vertex | startNode () const |
Vertex | currentNode () const |
Vertex | previousNode () const |
Vertex | exitNode () const |
const Graph & | getGraph () const |
Graph & | getGraph () |
std::vector < base::AttributeBase * > | getArguments () const |
Return an ordered list of this funcion's arguments. | |
base::AttributeBase * | getResult () const |
Get the return value of this program. | |
void | addArgument (base::AttributeBase *a) |
void | setResult (base::AttributeBase *r) |
Will store the result in this attribute. | |
void | clearArguments () |
Clear the arguments vector and release all base::AttributeBase resources. | |
bool | isRunning () const |
Returns true if the program is running. | |
bool | isPaused () const |
Returns true if the program is paused. | |
bool | isStopped () const |
Returns true if the program is not executing (stopped) or not loaded. | |
bool | inError () const |
Returns true if the program is in error. | |
Status::ProgramStatus | getStatus () const |
Return the current status of the program. | |
void | loaded (ExecutionEngine *ee) |
Called by the ExecutionEngine ee to tell this object it is being loaded. | |
void | unloaded () |
Called by the ExecutionEngine ee to tell this object it is being unloaded. | |
bool | isLoaded () |
Returns true if this object is loaded in an ExecutionEngine. | |
ExecutionEngine * | getEngine () |
Returns the ExecutionEngine this object is loaded into or null otherwise. | |
Protected Member Functions | |
bool | executeUntil () |
bool | executeStep () |
Protected Attributes | |
Graph | program |
The graph containing this function. | |
Vertex | startv |
Vertex | exitv |
std::string | myName |
The (unique) name of this program. | |
std::string | _text |
Program text. | |
std::vector < base::AttributeBase * > | args |
Ordered arguments (are also in the repository). | |
base::AttributeBase * | retn |
bool | pausing |
bool | mstep |
bool | munload_on_stop |
ServicePtr | context |
Status::ProgramStatus | pStatus |
ExecutionEngine * | engine |
This class represents a function.
It has much in common with a program but is only used for storing a Graph.
Definition at line 59 of file FunctionGraph.hpp.
RTT::FunctionGraph::FunctionGraph | ( | const std::string & | name, |
bool | unload_on_stop | ||
) |
Create a FunctionGraph with a given name.
name | The name of this script. |
unload_on_stop | Set to true to force an unload when the script stops or an error is encountered. The unload is forced by returning false in execute(), as defined in the ExecutableInterface. This flag should only be set to true for scripts that don't have a service associated (see setProgramService() ), since the service is destroyed when the function is unloaded. You can override this behavior after construction by using setUnloadOnStop(). |
Definition at line 59 of file FunctionGraph.cpp.
References program.
Referenced by copy().
FunctionGraph * RTT::FunctionGraph::copy | ( | std::map< const base::DataSourceBase *, base::DataSourceBase * > & | replacementdss | ) | const [virtual] |
Clone this Program.
This will produce a completely new instance, that has nothing in common with this one. It takes care to properly map identical DataSources to identical DataSources.
alreadyMappedData | A map of some DataSources used in this program to new DataSources that should replace them in the new Program. This is provided, because in some cases the outside world also keeps references to datasources used somewhere in this programgraph. It is then important that when this Program is copied, the outside world has a way to get a reference to the corresponding datasources in the new program. We do this by allowing it to map some datasources itself, and simply provide us a list of its mappings. |
Implements RTT::scripting::ProgramInterface.
Definition at line 383 of file FunctionGraph.cpp.
References args, RTT::base::AttributeBase::copy(), finish(), FunctionGraph(), getName(), program, and setResult().
bool RTT::FunctionGraph::execute | ( | ) | [virtual] |
Execute as much actions until the program needs to wait on a condition to become true.
When paused, only execute one action.
Implements RTT::scripting::ProgramInterface.
Definition at line 199 of file FunctionGraph.cpp.
References RTT::scripting::ProgramInterface::Status::error, RTT::scripting::ProgramInterface::Status::paused, RTT::scripting::ProgramInterface::Status::running, and RTT::scripting::ProgramInterface::Status::stopped.
ExecutionEngine* RTT::base::ExecutableInterface::getEngine | ( | ) | [inline, inherited] |
Returns the ExecutionEngine this object is loaded into or null otherwise.
Definition at line 102 of file ExecutableInterface.hpp.
Referenced by RTT::scripting::StateMachine::loading(), and RTT::scripting::StateMachine::~StateMachine().
bool RTT::base::ExecutableInterface::isLoaded | ( | ) | [inline, inherited] |
Returns true if this object is loaded in an ExecutionEngine.
Definition at line 95 of file ExecutableInterface.hpp.
Referenced by pause(), RTT::ExecutionEngine::removeFunction(), start(), step(), and RTT::scripting::StateMachine::~StateMachine().
void RTT::base::ExecutableInterface::loaded | ( | ExecutionEngine * | ee | ) | [inline, inherited] |
Called by the ExecutionEngine ee to tell this object it is being loaded.
The engine pointer is set first and the user's loading() function is called next.
ee | The pointer to the engine calling us. |
Definition at line 70 of file ExecutableInterface.hpp.
Referenced by RTT::ExecutionEngine::runFunction().
void RTT::FunctionGraph::loading | ( | ) | [virtual] |
Informs this object that it got loaded in an ExecutionEngine.
Called by load() after the engine pointer is set.
Reimplemented from RTT::base::ExecutableInterface.
Definition at line 136 of file FunctionGraph.cpp.
References start().
virtual bool RTT::scripting::FunctionGraph::needsStart | ( | ) | const [inline, virtual] |
Returns true if a start() is necessary when this function is loaded with ExecutionEngine::runFunction().
Functions that unload_on_stop == true don't need to be started since they will start themselves when loaded in the EE.
Implements RTT::scripting::ProgramInterface.
Definition at line 156 of file FunctionGraph.hpp.
void RTT::FunctionGraph::setName | ( | const std::string & | _name | ) |
Set the name of this program.
Only valid before endProgram() is called.
Definition at line 363 of file FunctionGraph.cpp.
References myName.
void RTT::FunctionGraph::setProgramService | ( | ServicePtr | myservice | ) |
Set a service that manages this script.
The service will be destroyed when this function is unloaded.
Definition at line 126 of file FunctionGraph.cpp.
void RTT::FunctionGraph::setUnloadOnStop | ( | bool | unload_on_stop | ) |
Sets the unloading policy on stop or error.
unload_on_stop | See the description of the constructor of this class. |
Definition at line 131 of file FunctionGraph.cpp.
void RTT::base::ExecutableInterface::unloaded | ( | ) | [inline, inherited] |
Called by the ExecutionEngine ee to tell this object it is being unloaded.
The user's loading() function is called first and the engine pointer is cleared next.
Definition at line 78 of file ExecutableInterface.hpp.
Referenced by RTT::ExecutionEngine::removeFunction().
void RTT::FunctionGraph::unloading | ( | ) | [virtual] |
Informs this object that it got unloaded from an ExecutionEngine.
Called by unload() before the engine pointer is cleared.
Reimplemented from RTT::base::ExecutableInterface.
Definition at line 143 of file FunctionGraph.cpp.