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
00153 void finish();
00154
00155 virtual bool start();
00156
00157 virtual bool execute();
00158
00159 virtual void loading();
00160
00161 virtual void unloading();
00162
00163 virtual bool stop();
00164
00165 virtual bool pause();
00166
00167 virtual bool step();
00168
00169 virtual bool stepDone() const;
00170
00174 virtual void reset();
00175
00176 virtual int getLineNumber() const;
00177
00178 virtual const std::string& getName() const;
00179
00180 virtual FunctionGraph* copy( std::map<const base::DataSourceBase*, base::DataSourceBase*>& replacementdss ) const;
00181
00182 virtual FunctionGraph* clone() const;
00183
00188 void setName(const std::string& _name);
00189
00193 void setText( const std::string& t);
00194
00195 std::string getText() const;
00196
00197 void debugPrintout() const;
00198
00199 Vertex startNode() const
00200 {
00201 return startv;
00202 }
00203
00204 Vertex currentNode() const
00205 {
00206 return current;
00207 }
00208
00209 Vertex previousNode() const
00210 {
00211 return previous;
00212 }
00213
00214 Vertex exitNode() const
00215 {
00216 return exitv;
00217 }
00218
00219 const Graph& getGraph() const
00220 {
00221 return program;
00222 }
00223
00224 Graph& getGraph()
00225 {
00226 return program;
00227 }
00228
00232 std::vector<base::AttributeBase*> getArguments() const {
00233 return args;
00234 }
00235
00236 base::AttributeBase* getResult() const {
00237 return retn;
00238 }
00239
00240 void addArgument( base::AttributeBase* a) {
00241 args.push_back(a);
00242 }
00243
00247 void setResult( base::AttributeBase* r) { retn = r; }
00248
00252 void clearArguments();
00253 };
00254
00255
00256 }}
00257
00258 #endif