00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038 #ifndef FUNCTION_GRAPH_HPP
00039 #define FUNCTION_GRAPH_HPP
00040
00041 #include "VertexNode.hpp"
00042 #include "EdgeCondition.hpp"
00043 #include "CommandNOP.hpp"
00044 #include "rtt-scripting-config.h"
00045 #include "../base/AttributeBase.hpp"
00046 #include "ProgramInterface.hpp"
00047
00048 namespace RTT
00049 { namespace scripting {
00050
00051 typedef boost::shared_ptr<FunctionGraph> FunctionGraphPtr;
00052 typedef boost::weak_ptr<FunctionGraph> FunctionGraphWPtr;
00053
00059 class RTT_SCRIPTING_API FunctionGraph
00060 :public ProgramInterface
00061 {
00062 public:
00063 typedef EdgeCondition::EdgeProperty EdgeProperty;
00064 typedef VertexNode::VertProperty VertProperty;
00065
00066 typedef boost::adjacency_list<boost::vecS,
00067 boost::listS,
00068 boost::directedS,
00069 VertProperty,
00070 EdgeProperty> Graph;
00071 typedef boost::graph_traits<Graph>::vertex_descriptor Vertex;
00072 typedef boost::graph_traits<Graph>::edge_descriptor Edge;
00073
00074 private:
00078 Vertex current;
00079
00083 Vertex previous;
00084
00085 protected:
00089 Graph program;
00090
00091 Vertex startv;
00092 Vertex exitv;
00093
00097 std::string myName;
00098
00102 std::string _text;
00103
00107 std::vector<base::AttributeBase*> args;
00108
00109 base::AttributeBase* retn;
00110
00111 bool pausing;
00112 bool mstep;
00113 bool munload_on_stop;
00114
00115 bool executeUntil();
00116 bool executeStep();
00117
00118 ServicePtr context;
00119 public:
00129 FunctionGraph( const std::string& name, bool unload_on_stop );
00130
00134 FunctionGraph( const FunctionGraph& orig );
00135
00136 ~FunctionGraph();
00137
00142 void setProgramService(ServicePtr myservice);
00143
00148 void setUnloadOnStop(bool unload_on_stop);
00149
00156 virtual bool needsStart() const { return !munload_on_stop; }
00157
00161 void finish();
00162
00163 virtual bool start();
00164
00165 virtual bool execute();
00166
00167 virtual void loading();
00168
00169 virtual void unloading();
00170
00171 virtual bool stop();
00172
00173 virtual bool pause();
00174
00175 virtual bool step();
00176
00177 virtual bool stepDone() const;
00178
00182 virtual void reset();
00183
00184 virtual int getLineNumber() const;
00185
00186 virtual const std::string& getName() const;
00187
00188 virtual FunctionGraph* copy( std::map<const base::DataSourceBase*, base::DataSourceBase*>& replacementdss ) const;
00189
00190 virtual FunctionGraph* clone() const;
00191
00196 void setName(const std::string& _name);
00197
00201 void setText( const std::string& t);
00202
00203 std::string getText() const;
00204
00205 void debugPrintout() const;
00206
00207 Vertex startNode() const
00208 {
00209 return startv;
00210 }
00211
00212 Vertex currentNode() const
00213 {
00214 return current;
00215 }
00216
00217 Vertex previousNode() const
00218 {
00219 return previous;
00220 }
00221
00222 Vertex exitNode() const
00223 {
00224 return exitv;
00225 }
00226
00227 const Graph& getGraph() const
00228 {
00229 return program;
00230 }
00231
00232 Graph& getGraph()
00233 {
00234 return program;
00235 }
00236
00240 std::vector<base::AttributeBase*> getArguments() const {
00241 return args;
00242 }
00243
00244 base::AttributeBase* getResult() const {
00245 return retn;
00246 }
00247
00248 void addArgument( base::AttributeBase* a) {
00249 args.push_back(a);
00250 }
00251
00255 void setResult( base::AttributeBase* r) { retn = r; }
00256
00260 void clearArguments();
00261 };
00262
00263
00264 }}
00265
00266 #endif