FunctionGraph.hpp
Go to the documentation of this file.
1 /***************************************************************************
2  tag: Peter Soetens Mon Jan 19 14:11:21 CET 2004 FunctionGraph.hpp
3 
4  FunctionGraph.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 FUNCTION_GRAPH_HPP
39 #define FUNCTION_GRAPH_HPP
40 
41 #include "VertexNode.hpp"
42 #include "EdgeCondition.hpp"
43 #include "CommandNOP.hpp"
44 #include "rtt-scripting-config.h"
45 #include "../base/AttributeBase.hpp"
46 #include "ProgramInterface.hpp"
47 
48 namespace RTT
49 { namespace scripting {
50 
51  typedef boost::shared_ptr<FunctionGraph> FunctionGraphPtr;
52  typedef boost::weak_ptr<FunctionGraph> FunctionGraphWPtr;
53 
59  class RTT_SCRIPTING_API FunctionGraph
60  :public ProgramInterface
61  {
62  public:
65 
66  typedef boost::adjacency_list<boost::vecS,
67  boost::listS,
68  boost::directedS,
69  VertProperty,
70  EdgeProperty> Graph;
71  typedef boost::graph_traits<Graph>::vertex_descriptor Vertex;
72  typedef boost::graph_traits<Graph>::edge_descriptor Edge;
73 
74  private:
78  Vertex current;
79 
83  Vertex previous;
84 
85  protected:
89  Graph program;
90 
91  Vertex startv;
92  Vertex exitv;
93 
97  std::string myName;
98 
102  std::string _text;
103 
107  std::vector<base::AttributeBase*> args;
108 
110 
111  bool pausing;
112  bool mstep;
114 
115  bool executeUntil();
116  bool executeStep();
117 
119  public:
129  FunctionGraph( const std::string& name, bool unload_on_stop );
130 
134  FunctionGraph( const FunctionGraph& orig );
135 
136  ~FunctionGraph();
137 
142  void setProgramService(ServicePtr myservice);
143 
148  void setUnloadOnStop(bool unload_on_stop);
149 
156  virtual bool needsStart() const { return !munload_on_stop; }
157 
161  void finish();
162 
163  virtual bool start();
164 
165  virtual bool execute();
166 
167  virtual void loading();
168 
169  virtual void unloading();
170 
171  virtual bool stop();
172 
173  virtual bool pause();
174 
175  virtual bool step();
176 
177  virtual bool stepDone() const;
178 
182  virtual void reset();
183 
184  virtual int getLineNumber() const;
185 
186  virtual const std::string& getName() const;
187 
188  virtual FunctionGraph* copy( std::map<const base::DataSourceBase*, base::DataSourceBase*>& replacementdss ) const;
189 
190  virtual FunctionGraph* clone() const;
191 
196  void setName(const std::string& _name);
197 
201  void setText( const std::string& t);
202 
203  std::string getText() const;
204 
205  void debugPrintout() const;
206 
207  Vertex startNode() const
208  {
209  return startv;
210  }
211 
212  Vertex currentNode() const
213  {
214  return current;
215  }
216 
217  Vertex previousNode() const
218  {
219  return previous;
220  }
221 
222  Vertex exitNode() const
223  {
224  return exitv;
225  }
226 
227  const Graph& getGraph() const
228  {
229  return program;
230  }
231 
232  Graph& getGraph()
233  {
234  return program;
235  }
236 
240  std::vector<base::AttributeBase*> getArguments() const {
241  return args;
242  }
243 
245  return retn;
246  }
247 
249  args.push_back(a);
250  }
251 
255  void setResult( base::AttributeBase* r) { retn = r; }
256 
260  void clearArguments();
261  };
262 
263 
264 }}
265 
266 #endif
const Graph & getGraph() const
boost::shared_ptr< FunctionGraph > FunctionGraphPtr
std::vector< base::AttributeBase * > args
boost::adjacency_list< boost::vecS, boost::listS, boost::directedS, VertProperty, EdgeProperty > Graph
void setResult(base::AttributeBase *r)
base::AttributeBase * retn
VertexNode::VertProperty VertProperty
boost::shared_ptr< Service > ServicePtr
Definition: rtt-fwd.hpp:86
std::vector< base::AttributeBase * > getArguments() const
boost::graph_traits< Graph >::edge_descriptor Edge
void addArgument(base::AttributeBase *a)
virtual bool needsStart() const
boost::graph_traits< Graph >::vertex_descriptor Vertex
base::AttributeBase * getResult() const
Contains TaskContext, Activity, OperationCaller, Operation, Property, InputPort, OutputPort, Attribute.
Definition: Activity.cpp:53
boost::weak_ptr< FunctionGraph > FunctionGraphWPtr
A Program represents a collection of instructions that can be stepwise executed.
EdgeCondition::EdgeProperty EdgeProperty
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 Fri Oct 25 2019 03:59:33