FunctionGraph.hpp

00001 /***************************************************************************
00002   tag: Peter Soetens  Mon Jan 19 14:11:21 CET 2004  FunctionGraph.hpp
00003 
00004                         FunctionGraph.hpp -  description
00005                            -------------------
00006     begin                : Mon January 19 2004
00007     copyright            : (C) 2004 Peter Soetens
00008     email                : peter.soetens@mech.kuleuven.ac.be
00009 
00010  ***************************************************************************
00011  *   This library is free software; you can redistribute it and/or         *
00012  *   modify it under the terms of the GNU General Public                   *
00013  *   License as published by the Free Software Foundation;                 *
00014  *   version 2 of the License.                                             *
00015  *                                                                         *
00016  *   As a special exception, you may use this file as part of a free       *
00017  *   software library without restriction.  Specifically, if other files   *
00018  *   instantiate templates or use macros or inline functions from this     *
00019  *   file, or you compile this file and link it with other files to        *
00020  *   produce an executable, this file does not by itself cause the         *
00021  *   resulting executable to be covered by the GNU General Public          *
00022  *   License.  This exception does not however invalidate any other        *
00023  *   reasons why the executable file might be covered by the GNU General   *
00024  *   Public License.                                                       *
00025  *                                                                         *
00026  *   This library is distributed in the hope that it will be useful,       *
00027  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
00028  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU     *
00029  *   Lesser General Public License for more details.                       *
00030  *                                                                         *
00031  *   You should have received a copy of the GNU General Public             *
00032  *   License along with this library; if not, write to the Free Software   *
00033  *   Foundation, Inc., 59 Temple Place,                                    *
00034  *   Suite 330, Boston, MA  02111-1307  USA                                *
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 "AttributeBase.hpp"
00045 #include "ProgramInterface.hpp"
00046 
00047 namespace RTT
00048 {
00049     class FunctionGraph;
00050     typedef boost::shared_ptr<FunctionGraph> FunctionGraphPtr;
00051     typedef boost::weak_ptr<FunctionGraph> FunctionGraphWPtr;
00052     class TaskObject;
00053 
00059     class RTT_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<AttributeBase*> args;
00108 
00109         bool pausing;
00110         bool mstep;
00111 
00112         bool executeUntil();
00113         bool executeStep();
00114 
00115         virtual void handleUnload();
00116 
00117         TaskObject* context;
00118     public:
00122         FunctionGraph( const std::string& _name );
00123 
00127         FunctionGraph( const FunctionGraph& orig );
00128 
00129         ~FunctionGraph();
00130 
00131         void setProgramTask(TaskObject* mytask);
00132 
00136         void finish();
00137 
00138         virtual bool start();
00139 
00140         virtual bool execute();
00141 
00142         virtual bool stop();
00143 
00144         virtual bool pause();
00145 
00146         virtual bool step();
00147 
00148         virtual bool stepDone() const;
00149 
00153         virtual void reset();
00154 
00155         virtual int  getLineNumber() const;
00156 
00157         virtual const std::string& getName() const;
00158 
00159         virtual FunctionGraph* copy( std::map<const DataSourceBase*, DataSourceBase*>& replacementdss ) const;
00160 
00161         virtual FunctionGraph* clone() const;
00162 
00167         void setName(const std::string& _name);
00168 
00172         void setText( const std::string& t);
00173 
00174         std::string getText() const;
00175 
00176         void debugPrintout() const;
00177 
00178         Vertex startNode() const
00179         {
00180             return startv;
00181         }
00182 
00183         Vertex exitNode() const
00184         {
00185             return exitv;
00186         }
00187 
00188         const Graph& getGraph() const
00189         {
00190             return program;
00191         }
00192 
00193         Graph& getGraph()
00194         {
00195             return program;
00196         }
00197 
00201         std::vector<AttributeBase*> getArguments() const {
00202             return args;
00203         }
00204 
00205         void addArgument( AttributeBase* a) {
00206             args.push_back(a);
00207         }
00208 
00212         void clearArguments();
00213     };
00214 
00215 
00216 }
00217 
00218 #endif
Generated on Thu Dec 23 13:22:37 2010 for Orocos Real-Time Toolkit by  doxygen 1.6.3