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

This class builds a program consisting of data contained in a program graph tree, based on the Boost Graph Library. More...

#include <rtt/scripting/FunctionGraphBuilder.hpp>

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
 
typedef FunctionGraph::Vertex CommandNode
 A CommandNode serves as a token to construct a vertex or node, containing a command. More...
 
typedef FunctionGraph::Edge ConditionEdge
 A ConditionEdge serves as a token to construct an edge, containing a condition. More...
 

Public Member Functions

 FunctionGraphBuilder ()
 Constructs a Function graph builder. More...
 
 ~FunctionGraphBuilder ()
 
void setLineNumber (int ln)
 Set the line number of the build command node. More...
 
void setName (const std::string &_name)
 
FunctionGraphPtr startFunction (const std::string &fname)
 Start building a new function. More...
 
void returnFunction (ConditionInterface *cond, int line)
 Function return is detected inside the function. More...
 
FunctionGraphPtr endFunction (int line=0)
 Finish building the function and return the result. More...
 
FunctionGraphPtr getFunction ()
 Return a pointer to the function being built, zero if none. More...
 
void startIfStatement (ConditionInterface *cond, int linenumber)
 
void endIfBlock (int linenumber)
 
void endElseBlock (int linenumber)
 
void startWhileStatement (ConditionInterface *cond, int linenumber)
 
void endWhileBlock (int linenumber)
 
bool inLoop ()
 
bool breakLoop ()
 
CommandNode addCommand (ConditionInterface *cond, base::ActionInterface *com)
 Add a new command from the build CommandNode under a condition. More...
 
void addConditionEdge (ConditionInterface *cond, CommandNode vert)
 Add an edge from the build CommandNode to the given CommandNode without changing the build CommandNode. More...
 
void closeConditionEdge (CommandNode vert, ConditionInterface *cond)
 Add an edge between the given CommandNode and the build CommandNode. More...
 
CommandNode moveTo (CommandNode _build, CommandNode _next, int linenr)
 Select an already added CommandNode. More...
 
void setCommand (base::ActionInterface *comm)
 Sets a new Command on the build CommandNode. More...
 
base::ActionInterfacegetCommand (CommandNode cn)
 Get the Command on a given CommandNode. More...
 
void setCommand (CommandNode vert, base::ActionInterface *comm)
 Sets a (new) command on a given CommandNode. More...
 
CommandNode appendFunction (ConditionInterface *cond, FunctionGraphPtr fn, std::vector< base::DataSourceBase::shared_ptr > fnargs)
 Append a function to the build CommandNode. More...
 
CommandNode setFunction (FunctionGraphPtr fn, std::vector< base::DataSourceBase::shared_ptr > fnargs)
 Put a function in the build CommandNode. More...
 
CommandNode proceedToNext (int line_nr=0)
 Proceed to the 'next' CommandNode. More...
 
CommandNode proceedToNext (ConditionInterface *cond, int line_nr=0)
 Proceed to the 'next' CommandNode and add an edge with a condition. More...
 
void connectToNext (CommandNode v, ConditionInterface *cond)
 Connect the given CommandNode to the 'next' CommandNode. More...
 
CommandNode buildNode () const
 Return the build CommandNode. More...
 
size_t buildEdges () const
 Return the number of edges of the build CommandNode. More...
 
CommandNode nextNode () const
 Return the next CommandNode. More...
 

Public Attributes

CommandNode build
 The node which will be built next. More...
 
CommandNode next
 The node which will be built next. More...
 

Detailed Description

This class builds a program consisting of data contained in a program graph tree, based on the Boost Graph Library.

Definition at line 59 of file FunctionGraphBuilder.hpp.

Member Typedef Documentation

A CommandNode serves as a token to construct a vertex or node, containing a command.

Definition at line 74 of file FunctionGraphBuilder.hpp.

A ConditionEdge serves as a token to construct an edge, containing a condition.

Definition at line 80 of file FunctionGraphBuilder.hpp.

typedef boost::graph_traits<Graph>::edge_descriptor RTT::scripting::FunctionGraphBuilder::Edge

Definition at line 68 of file FunctionGraphBuilder.hpp.

Definition at line 63 of file FunctionGraphBuilder.hpp.

typedef boost::adjacency_list<boost::vecS, boost::listS, boost::directedS, VertProperty, EdgeProperty> RTT::scripting::FunctionGraphBuilder::Graph

Definition at line 66 of file FunctionGraphBuilder.hpp.

typedef boost::graph_traits<Graph>::vertex_descriptor RTT::scripting::FunctionGraphBuilder::Vertex

Definition at line 67 of file FunctionGraphBuilder.hpp.

Definition at line 64 of file FunctionGraphBuilder.hpp.

Constructor & Destructor Documentation

RTT::FunctionGraphBuilder::FunctionGraphBuilder ( )

Constructs a Function graph builder.

Definition at line 65 of file FunctionGraphBuilder.cpp.

RTT::FunctionGraphBuilder::~FunctionGraphBuilder ( )

Definition at line 70 of file FunctionGraphBuilder.cpp.

Member Function Documentation

FunctionGraphBuilder::CommandNode RTT::FunctionGraphBuilder::addCommand ( ConditionInterface cond,
base::ActionInterface com 
)

Add a new command from the build CommandNode under a condition.

Returns
the 'new' build CommandNode.

Definition at line 120 of file FunctionGraphBuilder.cpp.

References build, next, RTT::scripting::VertexNode::normal_node, setCommand(), and RTT::scripting::vertex_exec.

void RTT::FunctionGraphBuilder::addConditionEdge ( ConditionInterface cond,
CommandNode  vert 
)

Add an edge from the build CommandNode to the given CommandNode without changing the build CommandNode.

Definition at line 130 of file FunctionGraphBuilder.cpp.

References build.

Referenced by appendFunction(), breakLoop(), endElseBlock(), endIfBlock(), endWhileBlock(), startIfStatement(), and startWhileStatement().

FunctionGraphBuilder::CommandNode RTT::FunctionGraphBuilder::appendFunction ( ConditionInterface cond,
FunctionGraphPtr  fn,
std::vector< base::DataSourceBase::shared_ptr fnargs 
)

Append a function to the build CommandNode.

Parameters
fnThe Function to append from the build CommandNode
condThe 'enter' condition
Returns
the last CommandNode of the appended function.

This can be used if a function must be called conditionally.

Definition at line 233 of file FunctionGraphBuilder.cpp.

References RTT::scripting::CommandComposite::add(), addConditionEdge(), build, buildNode(), connectToNext(), RTT::scripting::VertexNode::func_exit_node, RTT::scripting::VertexNode::func_start_node, getCommand(), RTT::scripting::VertexNode::normal_node, setCommand(), and RTT::scripting::vertex_exec.

Referenced by setFunction().

bool RTT::FunctionGraphBuilder::breakLoop ( )
size_t RTT::FunctionGraphBuilder::buildEdges ( ) const

Return the number of edges of the build CommandNode.

Definition at line 202 of file FunctionGraphBuilder.cpp.

References build.

FunctionGraphBuilder::CommandNode RTT::FunctionGraphBuilder::buildNode ( ) const

Return the build CommandNode.

Definition at line 197 of file FunctionGraphBuilder.cpp.

References build.

Referenced by appendFunction().

void RTT::FunctionGraphBuilder::closeConditionEdge ( CommandNode  vert,
ConditionInterface cond 
)

Add an edge between the given CommandNode and the build CommandNode.

Definition at line 135 of file FunctionGraphBuilder.cpp.

References build.

void RTT::FunctionGraphBuilder::connectToNext ( CommandNode  v,
ConditionInterface cond 
)

Connect the given CommandNode to the 'next' CommandNode.

Definition at line 192 of file FunctionGraphBuilder.cpp.

References next.

Referenced by appendFunction().

void RTT::FunctionGraphBuilder::endElseBlock ( int  linenumber)

Definition at line 426 of file FunctionGraphBuilder.cpp.

References addConditionEdge(), moveTo(), and next.

FunctionGraphPtr RTT::FunctionGraphBuilder::endFunction ( int  line = 0)

Finish building the function and return the result.

Returns
the finished function.

Definition at line 98 of file FunctionGraphBuilder.cpp.

References build, next, and RTT::scripting::vertex_command.

void RTT::FunctionGraphBuilder::endIfBlock ( int  linenumber)

Definition at line 411 of file FunctionGraphBuilder.cpp.

References addConditionEdge(), moveTo(), and next.

void RTT::FunctionGraphBuilder::endWhileBlock ( int  linenumber)

Definition at line 451 of file FunctionGraphBuilder.cpp.

References addConditionEdge(), moveTo(), and next.

ActionInterface * RTT::FunctionGraphBuilder::getCommand ( CommandNode  cn)

Get the Command on a given CommandNode.

Definition at line 149 of file FunctionGraphBuilder.cpp.

References RTT::scripting::vertex_command.

Referenced by appendFunction().

FunctionGraphPtr RTT::FunctionGraphBuilder::getFunction ( )

Return a pointer to the function being built, zero if none.

Definition at line 93 of file FunctionGraphBuilder.cpp.

bool RTT::FunctionGraphBuilder::inLoop ( )

Definition at line 463 of file FunctionGraphBuilder.cpp.

Referenced by breakLoop().

FunctionGraphBuilder::CommandNode RTT::FunctionGraphBuilder::moveTo ( CommandNode  _build,
CommandNode  _next,
int  linenr 
)

Select an already added CommandNode.

Returns
the previous CommandNode.

Definition at line 140 of file FunctionGraphBuilder.cpp.

References build, next, and setLineNumber().

Referenced by endElseBlock(), endIfBlock(), and endWhileBlock().

FunctionGraphBuilder::CommandNode RTT::FunctionGraphBuilder::nextNode ( ) const

Return the next CommandNode.

Definition at line 207 of file FunctionGraphBuilder.cpp.

References next.

FunctionGraphBuilder::CommandNode RTT::FunctionGraphBuilder::proceedToNext ( int  line_nr = 0)

Proceed to the 'next' CommandNode.

Parameters
line_nrThe line number of the 'build' command.
Returns
The new build CommandNode.

Definition at line 182 of file FunctionGraphBuilder.cpp.

References build, next, RTT::scripting::VertexNode::normal_node, setLineNumber(), and RTT::scripting::vertex_exec.

Referenced by proceedToNext(), startIfStatement(), and startWhileStatement().

FunctionGraphBuilder::CommandNode RTT::FunctionGraphBuilder::proceedToNext ( ConditionInterface cond,
int  line_nr = 0 
)

Proceed to the 'next' CommandNode and add an edge with a condition.

Parameters
condThe condition under which to proceed to the next node.
line_nrThe line number of the 'build' command.
Returns
The new build CommandNode.

Definition at line 176 of file FunctionGraphBuilder.cpp.

References build, next, and proceedToNext().

void RTT::FunctionGraphBuilder::returnFunction ( ConditionInterface cond,
int  line 
)

Function return is detected inside the function.

Do not confuse with endFunction().

Parameters
condThe Condition under which to return.
lineThe line number of that line in the function.

Definition at line 86 of file FunctionGraphBuilder.cpp.

References build.

void RTT::FunctionGraphBuilder::setCommand ( base::ActionInterface comm)

Sets a new Command on the build CommandNode.

Definition at line 158 of file FunctionGraphBuilder.cpp.

References build.

Referenced by addCommand(), and appendFunction().

void RTT::FunctionGraphBuilder::setCommand ( CommandNode  vert,
base::ActionInterface comm 
)

Sets a (new) command on a given CommandNode.

Parameters
vertThe CommandNode to be adapted
commThe new Command to be executed in that node.

Definition at line 163 of file FunctionGraphBuilder.cpp.

References RTT::scripting::vertex_command.

FunctionGraphBuilder::CommandNode RTT::FunctionGraphBuilder::setFunction ( FunctionGraphPtr  fn,
std::vector< base::DataSourceBase::shared_ptr fnargs 
)

Put a function in the build CommandNode.

Parameters
fnThe Function to append from the build CommandNode
Returns
the last CommandNode of the appended function.

This function must/should be used when build has no edges yet leaving. Off course, edges can already be pointing to build of the previous command. That's why build can not be overwritten with the first node of the function, and we need to insert an extra edge from build to funcStart. That is why we use (until better solution found) the append Function.

Definition at line 373 of file FunctionGraphBuilder.cpp.

References appendFunction().

void RTT::FunctionGraphBuilder::setLineNumber ( int  ln)

Set the line number of the build command node.

Parameters
lnThe line number.

Definition at line 212 of file FunctionGraphBuilder.cpp.

References build, and RTT::scripting::vertex_command.

Referenced by moveTo(), and proceedToNext().

void RTT::FunctionGraphBuilder::setName ( const std::string &  _name)

Definition at line 172 of file FunctionGraphBuilder.cpp.

FunctionGraphPtr RTT::FunctionGraphBuilder::startFunction ( const std::string &  fname)

Start building a new function.

Definition at line 74 of file FunctionGraphBuilder.cpp.

References build, next, RTT::scripting::VertexNode::normal_node, and RTT::scripting::vertex_exec.

void RTT::FunctionGraphBuilder::startIfStatement ( ConditionInterface cond,
int  linenumber 
)
void RTT::FunctionGraphBuilder::startWhileStatement ( ConditionInterface cond,
int  linenumber 
)

Member Data Documentation

CommandNode RTT::scripting::FunctionGraphBuilder::build
CommandNode RTT::scripting::FunctionGraphBuilder::next

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