Orocos Real-Time Toolkit
2.8.3
|
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. More... | |
FunctionGraph (const FunctionGraph &orig) | |
Copy a FunctionGraph. More... | |
~FunctionGraph () | |
void | setProgramService (ServicePtr myservice) |
Set a service that manages this script. More... | |
void | setUnloadOnStop (bool unload_on_stop) |
Sets the unloading policy on stop or error. More... | |
virtual bool | needsStart () const |
Returns true if a start() is necessary when this function is loaded with ExecutionEngine::runFunction(). More... | |
void | finish () |
To be called after a function is constructed. More... | |
virtual bool | start () |
Start the execution of this program. More... | |
virtual bool | execute () |
Execute as much actions until the program needs to wait on a condition to become true. More... | |
virtual void | loading () |
Informs this object that it got loaded in an ExecutionEngine. More... | |
virtual void | unloading () |
Informs this object that it got unloaded from an ExecutionEngine. More... | |
virtual bool | stop () |
Stop the execution of this program. More... | |
virtual bool | pause () |
Pause or start-and-pause the execution of this program. More... | |
virtual bool | step () |
Execute a single action when paused. More... | |
virtual bool | stepDone () const |
virtual void | reset () |
Identical to stop();. More... | |
virtual int | getLineNumber () const |
Return the current 'line number' of the program. More... | |
virtual const std::string & | getName () const |
Programs can be refered to by name. More... | |
virtual FunctionGraph * | copy (std::map< const base::DataSourceBase *, base::DataSourceBase * > &replacementdss) const |
Clone this Program. More... | |
virtual FunctionGraph * | clone () const |
void | setName (const std::string &_name) |
Set the name of this program. More... | |
void | setText (const std::string &t) |
Set the program text. More... | |
std::string | getText () const |
Return the program text to which getLineNumber() refers. More... | |
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. More... | |
base::AttributeBase * | getResult () const |
Get the return value of this program. More... | |
void | addArgument (base::AttributeBase *a) |
void | setResult (base::AttributeBase *r) |
Will store the result in this attribute. More... | |
void | clearArguments () |
Clear the arguments vector and release all base::AttributeBase resources. More... | |
bool | isRunning () const |
Returns true if the program is running. More... | |
bool | isPaused () const |
Returns true if the program is paused. More... | |
bool | isStopped () const |
Returns true if the program is not executing (stopped) or not loaded. More... | |
bool | inError () const |
Returns true if the program is in error. More... | |
Status::ProgramStatus | getStatus () const |
Return the current status of the program. More... | |
void | loaded (ExecutionEngine *ee) |
Called by the ExecutionEngine ee to tell this object it is being loaded. More... | |
void | unloaded () |
Called by the ExecutionEngine ee to tell this object it is being unloaded. More... | |
bool | isLoaded () |
Returns true if this object is loaded in an ExecutionEngine. More... | |
ExecutionEngine * | getEngine () |
Returns the ExecutionEngine this object is loaded into or null otherwise. More... | |
Protected Member Functions | |
bool | executeUntil () |
bool | executeStep () |
Protected Attributes | |
Graph | program |
The graph containing this function. More... | |
Vertex | startv |
Vertex | exitv |
std::string | myName |
The (unique) name of this program. More... | |
std::string | _text |
Program text. More... | |
std::vector< base::AttributeBase * > | args |
Ordered arguments (are also in the repository). More... | |
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.
typedef boost::graph_traits<Graph>::edge_descriptor RTT::scripting::FunctionGraph::Edge |
Definition at line 72 of file FunctionGraph.hpp.
Definition at line 63 of file FunctionGraph.hpp.
typedef boost::adjacency_list<boost::vecS, boost::listS, boost::directedS, VertProperty, EdgeProperty> RTT::scripting::FunctionGraph::Graph |
Definition at line 70 of file FunctionGraph.hpp.
typedef boost::graph_traits<Graph>::vertex_descriptor RTT::scripting::FunctionGraph::Vertex |
Definition at line 71 of file FunctionGraph.hpp.
Definition at line 64 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 exitv, RTT::scripting::VertexNode::normal_node, program, startv, and RTT::scripting::vertex_exec.
RTT::FunctionGraph::FunctionGraph | ( | const FunctionGraph & | orig | ) |
Copy a FunctionGraph.
Definition at line 69 of file FunctionGraph.cpp.
References args, RTT::base::AttributeBase::clone(), exitv, finish(), RTT::scripting::VertexNode::func_exit_node, RTT::scripting::VertexNode::func_start_node, getArguments(), program, retn, startv, and RTT::scripting::vertex_exec.
RTT::FunctionGraph::~FunctionGraph | ( | ) |
Definition at line 114 of file FunctionGraph.cpp.
References args, RTT::base::ExecutableInterface::getEngine(), RTT::base::ExecutableInterface::isLoaded(), and RTT::ExecutionEngine::removeFunction().
|
inline |
Definition at line 248 of file FunctionGraph.hpp.
Referenced by copy().
void RTT::FunctionGraph::clearArguments | ( | ) |
Clear the arguments vector and release all base::AttributeBase resources.
Definition at line 459 of file FunctionGraph.cpp.
References args.
|
virtual |
Implements RTT::scripting::ProgramInterface.
Definition at line 432 of file FunctionGraph.cpp.
References FunctionGraph().
|
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 addArgument(), args, RTT::base::AttributeBase::copy(), exitv, finish(), FunctionGraph(), getName(), munload_on_stop, program, retn, setResult(), and startv.
|
inline |
Definition at line 212 of file FunctionGraph.hpp.
void RTT::FunctionGraph::debugPrintout | ( | ) | const |
Definition at line 437 of file FunctionGraph.cpp.
References RTT::os::endl(), getName(), program, and RTT::scripting::vertex_command.
|
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, executeStep(), executeUntil(), mstep, munload_on_stop, RTT::scripting::ProgramInterface::Status::paused, pausing, RTT::scripting::ProgramInterface::pStatus, RTT::scripting::ProgramInterface::Status::running, RTT::scripting::ProgramInterface::Status::stopped, and RTT::scripting::ProgramInterface::Status::unknown.
|
protected |
Definition at line 290 of file FunctionGraph.cpp.
References edge_condition, RTT::scripting::ProgramInterface::Status::error, exitv, program, RTT::scripting::ProgramInterface::pStatus, reset(), stop(), and RTT::scripting::vertex_command.
Referenced by execute().
|
protected |
Definition at line 228 of file FunctionGraph.cpp.
References edge_condition, RTT::scripting::ProgramInterface::Status::error, exitv, munload_on_stop, pausing, program, RTT::scripting::ProgramInterface::pStatus, reset(), RTT::scripting::ProgramInterface::Status::running, stop(), and RTT::scripting::vertex_command.
Referenced by execute().
|
inline |
Definition at line 222 of file FunctionGraph.hpp.
void RTT::FunctionGraph::finish | ( | ) |
To be called after a function is constructed.
Definition at line 94 of file FunctionGraph.cpp.
References exitv, RTT::scripting::VertexNode::func_exit_node, RTT::scripting::VertexNode::func_start_node, program, reset(), startv, and RTT::scripting::vertex_exec.
Referenced by copy(), and FunctionGraph().
|
inlinevirtual |
Return an ordered list of this funcion's arguments.
Implements RTT::scripting::ProgramInterface.
Definition at line 240 of file FunctionGraph.hpp.
Referenced by FunctionGraph().
|
inlineinherited |
Returns the ExecutionEngine this object is loaded into or null otherwise.
Definition at line 102 of file ExecutableInterface.hpp.
Referenced by RTT::scripting::StateMachine::createEventTransition(), RTT::scripting::StateMachine::loading(), ~FunctionGraph(), and RTT::scripting::StateMachine::~StateMachine().
|
inline |
Definition at line 227 of file FunctionGraph.hpp.
|
inline |
Definition at line 232 of file FunctionGraph.hpp.
|
virtual |
Return the current 'line number' of the program.
Implements RTT::scripting::ProgramInterface.
Definition at line 378 of file FunctionGraph.cpp.
References program, and RTT::scripting::vertex_command.
|
virtual |
Programs can be refered to by name.
Implements RTT::scripting::ProgramInterface.
Definition at line 358 of file FunctionGraph.cpp.
References myName.
Referenced by copy(), and debugPrintout().
|
inlinevirtual |
Get the return value of this program.
Implements RTT::scripting::ProgramInterface.
Definition at line 244 of file FunctionGraph.hpp.
|
inlineinherited |
Return the current status of the program.
Definition at line 149 of file ProgramInterface.hpp.
|
virtual |
Return the program text to which getLineNumber() refers.
Implements RTT::scripting::ProgramInterface.
Definition at line 368 of file FunctionGraph.cpp.
References _text.
|
inlineinherited |
Returns true if the program is in error.
Definition at line 137 of file ProgramInterface.hpp.
Referenced by RTT::scripting::StateMachine::changeState(), RTT::scripting::StateMachine::deactivate(), RTT::scripting::StateMachine::executeProgram(), and RTT::scripting::ProgramService::ProgramService().
|
inlineinherited |
Returns true if this object is loaded in an ExecutionEngine.
Definition at line 95 of file ExecutableInterface.hpp.
Referenced by RTT::RemoveMsg::done(), pause(), RTT::ExecutionEngine::removeFunction(), start(), step(), ~FunctionGraph(), and RTT::scripting::StateMachine::~StateMachine().
|
inlineinherited |
Returns true if the program is paused.
Definition at line 127 of file ProgramInterface.hpp.
Referenced by RTT::scripting::ProgramService::ProgramService().
|
inlineinherited |
Returns true if the program is running.
Definition at line 122 of file ProgramInterface.hpp.
Referenced by RTT::scripting::ProgramService::ProgramService().
|
inlineinherited |
Returns true if the program is not executing (stopped) or not loaded.
Definition at line 132 of file ProgramInterface.hpp.
Referenced by RTT::scripting::StateMachine::executeProgram().
|
inlineinherited |
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::scripting::StateInterface::loaded(), and RTT::ExecutionEngine::runFunction().
|
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 munload_on_stop, and start().
|
inlinevirtual |
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.
|
virtual |
Pause or start-and-pause the execution of this program.
Implements RTT::scripting::ProgramInterface.
Definition at line 173 of file FunctionGraph.cpp.
References RTT::base::ExecutableInterface::isLoaded(), pausing, RTT::scripting::ProgramInterface::pStatus, reset(), and RTT::scripting::ProgramInterface::Status::stopped.
|
inline |
Definition at line 217 of file FunctionGraph.hpp.
|
virtual |
Identical to stop();.
Implements RTT::scripting::ProgramInterface.
Definition at line 345 of file FunctionGraph.cpp.
References exitv, startv, and stop().
Referenced by executeStep(), executeUntil(), finish(), pause(), and start().
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.
References context.
|
inline |
Will store the result in this attribute.
Definition at line 255 of file FunctionGraph.hpp.
Referenced by copy().
void RTT::FunctionGraph::setText | ( | const std::string & | t | ) |
Set the program text.
Definition at line 373 of file FunctionGraph.cpp.
References _text.
Referenced by RTT::scripting::ScriptParser::ScriptParser().
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.
References munload_on_stop.
|
virtual |
Start the execution of this program.
Implements RTT::scripting::ProgramInterface.
Definition at line 159 of file FunctionGraph.cpp.
References RTT::base::ExecutableInterface::isLoaded(), RTT::scripting::ProgramInterface::Status::paused, RTT::scripting::ProgramInterface::pStatus, reset(), RTT::scripting::ProgramInterface::Status::running, and RTT::scripting::ProgramInterface::Status::stopped.
Referenced by loading().
|
inline |
Definition at line 207 of file FunctionGraph.hpp.
|
virtual |
Execute a single action when paused.
Implements RTT::scripting::ProgramInterface.
Definition at line 185 of file FunctionGraph.cpp.
References RTT::base::ExecutableInterface::isLoaded(), mstep, RTT::scripting::ProgramInterface::Status::paused, and RTT::scripting::ProgramInterface::pStatus.
|
virtual |
Implements RTT::scripting::ProgramInterface.
Definition at line 194 of file FunctionGraph.cpp.
References mstep.
|
virtual |
Stop the execution of this program.
Implements RTT::scripting::ProgramInterface.
Definition at line 351 of file FunctionGraph.cpp.
References RTT::scripting::ProgramInterface::pStatus, and RTT::scripting::ProgramInterface::Status::stopped.
Referenced by executeStep(), executeUntil(), and reset().
|
inlineinherited |
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::processFunctions(), RTT::ExecutionEngine::removeFunction(), and RTT::ExecutionEngine::~ExecutionEngine().
|
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.
References context.
|
protected |
Program text.
Definition at line 102 of file FunctionGraph.hpp.
|
protected |
Ordered arguments (are also in the repository).
Definition at line 107 of file FunctionGraph.hpp.
Referenced by clearArguments(), copy(), FunctionGraph(), and ~FunctionGraph().
|
protected |
Definition at line 118 of file FunctionGraph.hpp.
Referenced by setProgramService(), and unloading().
|
protectedinherited |
Definition at line 61 of file ExecutableInterface.hpp.
|
protected |
Definition at line 92 of file FunctionGraph.hpp.
Referenced by copy(), executeStep(), executeUntil(), finish(), FunctionGraph(), and reset().
|
protected |
Definition at line 112 of file FunctionGraph.hpp.
Referenced by execute(), step(), and stepDone().
|
protected |
Definition at line 113 of file FunctionGraph.hpp.
Referenced by copy(), execute(), executeUntil(), loading(), and setUnloadOnStop().
|
protected |
The (unique) name of this program.
Definition at line 97 of file FunctionGraph.hpp.
|
protected |
Definition at line 111 of file FunctionGraph.hpp.
Referenced by execute(), executeUntil(), and pause().
|
protected |
The graph containing this function.
Definition at line 89 of file FunctionGraph.hpp.
Referenced by copy(), debugPrintout(), executeStep(), executeUntil(), finish(), FunctionGraph(), and getLineNumber().
|
protectedinherited |
Definition at line 80 of file ProgramInterface.hpp.
Referenced by execute(), executeStep(), executeUntil(), pause(), start(), step(), and stop().
|
protected |
Definition at line 109 of file FunctionGraph.hpp.
Referenced by copy(), and FunctionGraph().
|
protected |
Definition at line 91 of file FunctionGraph.hpp.
Referenced by copy(), finish(), FunctionGraph(), and reset().