Orocos Real-Time Toolkit
2.5.0
|
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/Types.hpp" 00049 #include "../Service.hpp" 00050 00051 namespace RTT { namespace scripting 00052 { 00060 class ValueChangeParser 00061 { 00062 // all the AssignVariableCommand we've built.. 00063 // This list is cleared in cleanup(). 00064 std::vector<base::ActionInterface*> assigncommands; 00065 00066 // the defined values... 00067 // This list is cleared in cleanup(). 00068 std::vector<base::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 types::TypeInfo of the type that was specified. We use it to get 00085 // hold of a Constant or a TaskVariable or ... 00086 types::TypeInfo* type; 00087 00088 void seenconstantdefinition(); 00089 void seenaliasdefinition(); 00090 void seenvariabledefinition(); 00091 void seenbaredefinition(); 00092 void seenparamdefinition(); 00093 void storedefinitionname( iter_t begin, iter_t end ); 00094 void seentype( iter_t begin, iter_t end ); 00095 void seensizehint(); 00096 void seenproperty(); 00097 00098 rule_t constantdefinition, aliasdefinition, variabledefinition, 00099 paramdefinition, baredefinition, 00100 vardecl, constdecl, baredecl, 00101 valuechange_parsers; 00102 00103 TaskContext* context; 00104 Service::shared_ptr mstore; 00105 ExpressionParser expressionparser; 00106 CommonParser& commonparser; 00107 00108 int sizehint; 00109 boost::shared_ptr<types::TypeInfoRepository> typerepos; 00110 00114 void cleanup(); 00115 public: 00125 ValueChangeParser( TaskContext* tc, CommonParser& cp, 00126 Service::shared_ptr storage, 00127 ExecutionEngine* caller); 00128 00133 void clear(); 00134 00140 void store( Service::shared_ptr other ); 00141 00148 void load( Service::shared_ptr source ); 00149 00157 base::ActionInterface* assignCommand() 00158 { 00159 if ( assigncommands.empty() ) 00160 return 0; 00161 return assigncommands.back(); 00162 } 00163 00164 std::vector<base::ActionInterface*> assignCommands() 00165 { 00166 return assigncommands; 00167 } 00168 00169 base::AttributeBase* lastDefinedValue() 00170 { 00171 if ( definedvalues.empty() ) 00172 return 0; 00173 return definedvalues.back(); 00174 } 00175 00176 std::vector<base::AttributeBase*> definedValues() 00177 { 00178 return definedvalues; 00179 } 00180 00181 std::string lastDefinedName() 00182 { 00183 if ( definednames.empty() ) 00184 return ""; 00185 return definednames.back(); 00186 } 00187 00188 std::vector<std::string> definedNames() 00189 { 00190 return definednames; 00191 } 00192 00193 std::vector<std::string> allDefinedNames() 00194 { 00195 return alldefinednames; 00196 } 00197 00203 rule_t& parser(); 00204 00210 rule_t& constantDefinitionParser(); 00211 00217 rule_t& variableDefinitionParser(); 00218 00224 rule_t& aliasDefinitionParser(); 00225 00231 rule_t& paramDefinitionParser(); 00232 00238 rule_t& bareDefinitionParser(); 00239 00244 void reset(); 00245 }; 00246 }} 00247 00248 #endif