Orocos Real-Time Toolkit  2.8.3
Public Types | Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
RTT::scripting::FunctionGraph Class Reference

This class represents a function. More...

#include <rtt/scripting/FunctionGraph.hpp>

Inheritance diagram for RTT::scripting::FunctionGraph:
RTT::scripting::ProgramInterface RTT::base::ExecutableInterface

Public Types

typedef EdgeCondition::EdgeProperty EdgeProperty
 
typedef VertexNode::VertProperty VertProperty
 
typedef boost::adjacency_list< boost::vecS, boost::listS, boost::directedS, VertProperty, EdgePropertyGraph
 
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 FunctionGraphcopy (std::map< const base::DataSourceBase *, base::DataSourceBase * > &replacementdss) const
 Clone this Program. More...
 
virtual FunctionGraphclone () 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 GraphgetGraph () const
 
GraphgetGraph ()
 
std::vector< base::AttributeBase * > getArguments () const
 Return an ordered list of this funcion's arguments. More...
 
base::AttributeBasegetResult () 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...
 
ExecutionEnginegetEngine ()
 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::AttributeBaseretn
 
bool pausing
 
bool mstep
 
bool munload_on_stop
 
ServicePtr context
 
Status::ProgramStatus pStatus
 
ExecutionEngineengine
 

Detailed Description

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.

Member Typedef Documentation

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.

Constructor & Destructor Documentation

RTT::FunctionGraph::FunctionGraph ( const std::string &  name,
bool  unload_on_stop 
)

Create a FunctionGraph with a given name.

Parameters
nameThe name of this script.
unload_on_stopSet 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.

Referenced by clone(), and copy().

RTT::FunctionGraph::FunctionGraph ( const FunctionGraph orig)
RTT::FunctionGraph::~FunctionGraph ( )

Member Function Documentation

void RTT::scripting::FunctionGraph::addArgument ( base::AttributeBase a)
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.

FunctionGraph * RTT::FunctionGraph::clone ( ) const
virtual

Implements RTT::scripting::ProgramInterface.

Definition at line 432 of file FunctionGraph.cpp.

References FunctionGraph().

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.

Parameters
alreadyMappedDataA 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.

Vertex RTT::scripting::FunctionGraph::currentNode ( ) const
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.

bool RTT::FunctionGraph::execute ( )
virtual
bool RTT::FunctionGraph::executeStep ( )
protected
bool RTT::FunctionGraph::executeUntil ( )
protected
Vertex RTT::scripting::FunctionGraph::exitNode ( ) const
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().

std::vector<base::AttributeBase*> RTT::scripting::FunctionGraph::getArguments ( ) const
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().

ExecutionEngine* RTT::base::ExecutableInterface::getEngine ( )
inlineinherited
const Graph& RTT::scripting::FunctionGraph::getGraph ( ) const
inline

Definition at line 227 of file FunctionGraph.hpp.

Graph& RTT::scripting::FunctionGraph::getGraph ( )
inline

Definition at line 232 of file FunctionGraph.hpp.

int RTT::FunctionGraph::getLineNumber ( ) const
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.

const std::string & RTT::FunctionGraph::getName ( ) const
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().

base::AttributeBase* RTT::scripting::FunctionGraph::getResult ( ) const
inlinevirtual

Get the return value of this program.

Implements RTT::scripting::ProgramInterface.

Definition at line 244 of file FunctionGraph.hpp.

Status::ProgramStatus RTT::scripting::ProgramInterface::getStatus ( ) const
inlineinherited

Return the current status of the program.

Definition at line 149 of file ProgramInterface.hpp.

std::string RTT::FunctionGraph::getText ( ) const
virtual

Return the program text to which getLineNumber() refers.

Implements RTT::scripting::ProgramInterface.

Definition at line 368 of file FunctionGraph.cpp.

References _text.

bool RTT::scripting::ProgramInterface::inError ( ) const
inlineinherited
bool RTT::base::ExecutableInterface::isLoaded ( )
inlineinherited

Returns true if this object is loaded in an ExecutionEngine.

Returns
true if so.

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().

bool RTT::scripting::ProgramInterface::isPaused ( ) const
inlineinherited

Returns true if the program is paused.

Definition at line 127 of file ProgramInterface.hpp.

Referenced by RTT::scripting::ProgramService::ProgramService().

bool RTT::scripting::ProgramInterface::isRunning ( ) const
inlineinherited

Returns true if the program is running.

Definition at line 122 of file ProgramInterface.hpp.

Referenced by RTT::scripting::ProgramService::ProgramService().

bool RTT::scripting::ProgramInterface::isStopped ( ) const
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().

void RTT::base::ExecutableInterface::loaded ( ExecutionEngine ee)
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.

Parameters
eeThe pointer to the engine calling us.

Definition at line 70 of file ExecutableInterface.hpp.

Referenced by RTT::scripting::StateInterface::loaded(), and 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 munload_on_stop, and start().

virtual bool RTT::scripting::FunctionGraph::needsStart ( ) const
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.

bool RTT::FunctionGraph::pause ( )
virtual
Vertex RTT::scripting::FunctionGraph::previousNode ( ) const
inline

Definition at line 217 of file FunctionGraph.hpp.

void RTT::FunctionGraph::reset ( )
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.

void RTT::scripting::FunctionGraph::setResult ( base::AttributeBase r)
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.

Parameters
unload_on_stopSee the description of the constructor of this class.

Definition at line 131 of file FunctionGraph.cpp.

References munload_on_stop.

bool RTT::FunctionGraph::start ( )
virtual
Vertex RTT::scripting::FunctionGraph::startNode ( ) const
inline

Definition at line 207 of file FunctionGraph.hpp.

bool RTT::FunctionGraph::step ( )
virtual
bool RTT::FunctionGraph::stepDone ( ) const
virtual

Implements RTT::scripting::ProgramInterface.

Definition at line 194 of file FunctionGraph.cpp.

References mstep.

bool RTT::FunctionGraph::stop ( )
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().

void RTT::base::ExecutableInterface::unloaded ( )
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().

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.

References context.

Member Data Documentation

std::string RTT::scripting::FunctionGraph::_text
protected

Program text.

Definition at line 102 of file FunctionGraph.hpp.

Referenced by getText(), and setText().

std::vector<base::AttributeBase*> RTT::scripting::FunctionGraph::args
protected

Ordered arguments (are also in the repository).

Definition at line 107 of file FunctionGraph.hpp.

Referenced by clearArguments(), copy(), FunctionGraph(), and ~FunctionGraph().

ServicePtr RTT::scripting::FunctionGraph::context
protected

Definition at line 118 of file FunctionGraph.hpp.

Referenced by setProgramService(), and unloading().

ExecutionEngine* RTT::base::ExecutableInterface::engine
protectedinherited

Definition at line 61 of file ExecutableInterface.hpp.

Vertex RTT::scripting::FunctionGraph::exitv
protected

Definition at line 92 of file FunctionGraph.hpp.

Referenced by copy(), executeStep(), executeUntil(), finish(), FunctionGraph(), and reset().

bool RTT::scripting::FunctionGraph::mstep
protected

Definition at line 112 of file FunctionGraph.hpp.

Referenced by execute(), step(), and stepDone().

bool RTT::scripting::FunctionGraph::munload_on_stop
protected

Definition at line 113 of file FunctionGraph.hpp.

Referenced by copy(), execute(), executeUntil(), loading(), and setUnloadOnStop().

std::string RTT::scripting::FunctionGraph::myName
protected

The (unique) name of this program.

Definition at line 97 of file FunctionGraph.hpp.

Referenced by getName(), and setName().

bool RTT::scripting::FunctionGraph::pausing
protected

Definition at line 111 of file FunctionGraph.hpp.

Referenced by execute(), executeUntil(), and pause().

Graph RTT::scripting::FunctionGraph::program
protected

The graph containing this function.

Definition at line 89 of file FunctionGraph.hpp.

Referenced by copy(), debugPrintout(), executeStep(), executeUntil(), finish(), FunctionGraph(), and getLineNumber().

Status::ProgramStatus RTT::scripting::ProgramInterface::pStatus
protectedinherited

Definition at line 80 of file ProgramInterface.hpp.

Referenced by execute(), executeStep(), executeUntil(), pause(), start(), step(), and stop().

base::AttributeBase* RTT::scripting::FunctionGraph::retn
protected

Definition at line 109 of file FunctionGraph.hpp.

Referenced by copy(), and FunctionGraph().

Vertex RTT::scripting::FunctionGraph::startv
protected

Definition at line 91 of file FunctionGraph.hpp.

Referenced by copy(), finish(), FunctionGraph(), and reset().


The documentation for this class was generated from the following files: