FunctionGraphBuilder.hpp
Go to the documentation of this file.
1 /***************************************************************************
2  tag: Peter Soetens Mon Jan 19 14:11:21 CET 2004 ProgramGraph.hpp
3 
4  ProgramGraph.hpp - description
5  -------------------
6  begin : Mon January 19 2004
7  copyright : (C) 2004 Peter Soetens
8  email : peter.soetens@mech.kuleuven.ac.be
9 
10  ***************************************************************************
11  * This library is free software; you can redistribute it and/or *
12  * modify it under the terms of the GNU General Public *
13  * License as published by the Free Software Foundation; *
14  * version 2 of the License. *
15  * *
16  * As a special exception, you may use this file as part of a free *
17  * software library without restriction. Specifically, if other files *
18  * instantiate templates or use macros or inline functions from this *
19  * file, or you compile this file and link it with other files to *
20  * produce an executable, this file does not by itself cause the *
21  * resulting executable to be covered by the GNU General Public *
22  * License. This exception does not however invalidate any other *
23  * reasons why the executable file might be covered by the GNU General *
24  * Public License. *
25  * *
26  * This library is distributed in the hope that it will be useful, *
27  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
28  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
29  * Lesser General Public License for more details. *
30  * *
31  * You should have received a copy of the GNU General Public *
32  * License along with this library; if not, write to the Free Software *
33  * Foundation, Inc., 59 Temple Place, *
34  * Suite 330, Boston, MA 02111-1307 USA *
35  * *
36  ***************************************************************************/
37 
38 #ifndef PROGRAMGRAPH_HPP
39 #define PROGRAMGRAPH_HPP
40 
41 #include "FunctionGraph.hpp"
42 #include "../base/DataSourceBase.hpp"
43 
44 #include <utility> // for std::pair
45 #include <stack>
46 #include <map>
47 #include <string>
48 #include <boost/graph/graph_traits.hpp>
49 
50 namespace RTT
51 { namespace scripting {
52 
53 
59  class RTT_SCRIPTING_API FunctionGraphBuilder
60  {
61  public:
62 
65 
66  typedef boost::adjacency_list<boost::vecS, boost::listS, boost::directedS, VertProperty, EdgeProperty> Graph;
67  typedef boost::graph_traits<Graph>::vertex_descriptor Vertex;
68  typedef boost::graph_traits<Graph>::edge_descriptor Edge;
69 
75 
81 
86 
88 
93  void setLineNumber( int ln );
94 
95  void setName(const std::string& _name);
96 
100  FunctionGraphPtr startFunction( const std::string& fname );
101 
109  void returnFunction( ConditionInterface* cond, int line );
110 
115  FunctionGraphPtr endFunction( int line = 0 );
116 
120  FunctionGraphPtr getFunction();
121 
122  void startIfStatement( ConditionInterface* cond, int linenumber );
123  void endIfBlock(int linenumber);
124  void endElseBlock(int linenumber);
125 
126  void startWhileStatement( ConditionInterface* cond, int linenumber );
127  void endWhileBlock(int linenumber);
128 
129  bool inLoop();
130  bool breakLoop();
131 
137  CommandNode addCommand( ConditionInterface* cond, base::ActionInterface* com );
138 
144  void addConditionEdge( ConditionInterface* cond, CommandNode vert );
145 
150  void closeConditionEdge( CommandNode vert, ConditionInterface* cond );
151 
157  CommandNode moveTo( CommandNode _build, CommandNode _next, int linenr );
158 
163  void setCommand( base::ActionInterface* comm );
164 
169  base::ActionInterface* getCommand( CommandNode cn );
170 
178  void setCommand( CommandNode vert, base::ActionInterface* comm);
179 
188  CommandNode appendFunction( ConditionInterface* cond, FunctionGraphPtr fn, std::vector<base::DataSourceBase::shared_ptr> fnargs);
189 
197  CommandNode setFunction( FunctionGraphPtr fn, std::vector<base::DataSourceBase::shared_ptr> fnargs);
198 
205  CommandNode proceedToNext( int line_nr = 0 );
206 
215  CommandNode proceedToNext( ConditionInterface* cond, int line_nr = 0 );
216 
220  void connectToNext( CommandNode v, ConditionInterface* cond );
221 
225  CommandNode buildNode() const;
226 
230  size_t buildEdges() const;
231 
235  CommandNode nextNode() const;
236 
240  CommandNode build;
241 
245  CommandNode next;
246 
247  private:
248 
250 
254  Graph* graph;
255 
264  std::stack<CommandNode> branch_stack;
265 
270  std::stack<CommandNode> break_stack;
271  };
272 }}
273 
274 #endif
275 
276 
This class builds a program consisting of data contained in a program graph tree, based on the Boost ...
boost::shared_ptr< FunctionGraph > FunctionGraphPtr
boost::graph_traits< Graph >::edge_descriptor Edge
This interface represents the concept of a condition which can be evaluated and return true or false...
std::stack< CommandNode > branch_stack
A stack which keeps track of branch points.
Based on the software pattern &#39;command&#39;, this interface allows execution of action objects...
boost::graph_traits< Graph >::vertex_descriptor Vertex
boost::graph_traits< Graph >::edge_descriptor Edge
boost::graph_traits< Graph >::vertex_descriptor Vertex
Contains TaskContext, Activity, OperationCaller, Operation, Property, InputPort, OutputPort, Attribute.
Definition: Activity.cpp:53
EdgeCondition::EdgeProperty EdgeProperty
boost::adjacency_list< boost::vecS, boost::listS, boost::directedS, VertProperty, EdgeProperty > Graph
boost::property< vertex_command_t, VertexNode, boost::property< vertex_exec_t, int, boost::property< boost::vertex_index_t, int > > > VertProperty
Definition: VertexNode.hpp:85
property< edge_condition_t, EdgeCondition, property< boost::edge_index_t, int > > EdgeProperty


rtt
Author(s): RTT Developers
autogenerated on Tue Jun 25 2019 19:33:24