ValueChangeParser.hpp

00001 /***************************************************************************
00002   tag: Peter Soetens  Mon Jan 19 14:11:26 CET 2004  ValueChangeParser.hpp
00003 
00004                         ValueChangeParser.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 VALUECHANGEPARSER_HPP
00039 #define VALUECHANGEPARSER_HPP
00040 
00041 #include "parser-types.hpp"
00042 
00043 #include "../Attribute.hpp"
00044 #include "CommonParser.hpp"
00045 #include "ExpressionParser.hpp"
00046 #include "PeerParser.hpp"
00047 #include "PropertyParser.hpp"
00048 #include "../Types.hpp"
00049 #include "../OperationInterface.hpp"
00050 
00051 namespace RTT { namespace detail
00052 {
00060   class ValueChangeParser
00061   {
00062       // all the AssignVariableCommand we've built..
00063       // This list is cleared in cleanup().
00064       std::vector<CommandInterface*> assigncommands;
00065 
00066       // the defined values...
00067       // This list is cleared in cleanup().
00068       std::vector<AttributeBase*> definedvalues;
00069 
00070       // the parsed variable or constant or alias or param
00071       // definition name.
00072       // This list is cleared in cleanup().
00073       std::vector<std::string> definednames;
00074 
00075       // A list of all the names stored in \a context.
00076       // this list is used to remove them when reset() is
00077       // called.
00078       std::vector<std::string> alldefinednames;
00079 
00080     // the name of the value of which we're currently parsing the
00081     // definition or assignment..
00082     std::string valuename;
00083 
00084     // A TypeInfo of the type that was specified.  We use it to get
00085     // hold of a Constant or a TaskVariable or ...
00086     TypeInfo* type;
00087 
00088     void seenconstantdefinition();
00089     void seenaliasdefinition();
00090     void seenvariabledefinition();
00091     void seenbaredefinition();
00092     void seenparamdefinition();
00093     void seenvariableassignment();
00094     void storedefinitionname( iter_t begin, iter_t end );
00095     void storename( iter_t begin, iter_t end );
00096     void storepeername();
00097     void seentype( iter_t begin, iter_t end );
00098     void seenindexassignment();
00099     void seensizehint();
00100     void seenproperty();
00101 
00102     rule_t constantdefinition, aliasdefinition, variabledefinition,
00103         variableassignment, variablechange, paramdefinition, baredefinition,
00104         vardecl, constdecl, baredecl;
00105 
00106       TaskContext* context;
00107       OperationInterface* mstore;
00108       ExpressionParser expressionparser;
00109       PeerParser peerparser;
00110       PropertyParser propparser;
00111       CommonParser& commonparser;
00112 
00113       DataSourceBase::shared_ptr index_ds;
00114 
00115       int sizehint;
00116       boost::shared_ptr<TypeInfoRepository> typerepos;
00117 
00121       void cleanup();
00122   public:
00132       ValueChangeParser( TaskContext* tc, CommonParser& cp, OperationInterface* storage= 0 );
00133 
00138       void clear();
00139 
00143       void store( OperationInterface* other );
00144 
00152     CommandInterface* assignCommand()
00153       {
00154           if ( assigncommands.empty() )
00155               return 0;
00156           return assigncommands.back();
00157       }
00158 
00159     std::vector<CommandInterface*> assignCommands()
00160       {
00161           return assigncommands;
00162       }
00163 
00164     AttributeBase* lastDefinedValue()
00165       {
00166           if ( definedvalues.empty() )
00167               return 0;
00168           return definedvalues.back();
00169       }
00170 
00171     std::vector<AttributeBase*> definedValues()
00172       {
00173           return definedvalues;
00174       }
00175 
00176     std::string lastDefinedName()
00177       {
00178           if ( definednames.empty() )
00179               return "";
00180           return definednames.back();
00181       }
00182 
00183     std::vector<std::string> definedNames()
00184       {
00185           return definednames;
00186       }
00187 
00188     std::vector<std::string> allDefinedNames()
00189       {
00190           return alldefinednames;
00191       }
00192 
00193 
00199     rule_t& constantDefinitionParser();
00200 
00206     rule_t& variableDefinitionParser();
00207 
00213     rule_t& variableAssignmentParser();
00214 
00220     rule_t& variableChangeParser();
00221 
00227     rule_t& aliasDefinitionParser();
00228 
00234     rule_t& paramDefinitionParser();
00235 
00241     rule_t& bareDefinitionParser();
00242 
00247     void reset();
00248   };
00249 }}
00250 
00251 #endif
Generated on Thu Dec 23 13:22:38 2010 for Orocos Real-Time Toolkit by  doxygen 1.6.3