Orocos Real-Time Toolkit  2.8.3
ValueChangeParser.hpp
Go to the documentation of this file.
1 /***************************************************************************
2  tag: Peter Soetens Mon Jan 19 14:11:26 CET 2004 ValueChangeParser.hpp
3 
4  ValueChangeParser.hpp - description
5  -------------------
6  begin : Mon January 19 2004
7  copyright : (C) 2004 Peter Soetens
8  email : peter.soetens@mech.kuleuven.ac.be
9 
10  ***************************************************************************
11  * This library is free software; you can redistribute it and/or *
12  * modify it under the terms of the GNU General Public *
13  * License as published by the Free Software Foundation; *
14  * version 2 of the License. *
15  * *
16  * As a special exception, you may use this file as part of a free *
17  * software library without restriction. Specifically, if other files *
18  * instantiate templates or use macros or inline functions from this *
19  * file, or you compile this file and link it with other files to *
20  * produce an executable, this file does not by itself cause the *
21  * resulting executable to be covered by the GNU General Public *
22  * License. This exception does not however invalidate any other *
23  * reasons why the executable file might be covered by the GNU General *
24  * Public License. *
25  * *
26  * This library is distributed in the hope that it will be useful, *
27  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
28  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
29  * Lesser General Public License for more details. *
30  * *
31  * You should have received a copy of the GNU General Public *
32  * License along with this library; if not, write to the Free Software *
33  * Foundation, Inc., 59 Temple Place, *
34  * Suite 330, Boston, MA 02111-1307 USA *
35  * *
36  ***************************************************************************/
37 
38 #ifndef VALUECHANGEPARSER_HPP
39 #define VALUECHANGEPARSER_HPP
40 
41 #include "parser-types.hpp"
42 
43 #include "../Attribute.hpp"
44 #include "CommonParser.hpp"
45 #include "ExpressionParser.hpp"
46 #include "PeerParser.hpp"
47 #include "PropertyParser.hpp"
48 #include "../types/Types.hpp"
49 #include "../Service.hpp"
50 
51 namespace RTT { namespace scripting
52 {
61  {
62  // all the AssignVariableCommand we've built..
63  // This list is cleared in cleanup().
64  std::vector<base::ActionInterface*> assigncommands;
65 
66  // the defined values...
67  // This list is cleared in cleanup().
68  std::vector<base::AttributeBase*> definedvalues;
69 
70  // the parsed variable or constant or alias or param
71  // definition name.
72  // This list is cleared in cleanup().
73  std::vector<std::string> definednames;
74 
75  // A list of all the names stored in \a context.
76  // this list is used to remove them when reset() is
77  // called.
78  std::vector<std::string> alldefinednames;
79 
80  // the name of the value of which we're currently parsing the
81  // definition or assignment..
82  std::string valuename;
83 
84  // A types::TypeInfo of the type that was specified. We use it to get
85  // hold of a Constant or a TaskVariable or ...
86  types::TypeInfo* type;
87 
88  void seenconstantdefinition();
89  void seenaliasdefinition();
90  void seenvariabledefinition();
91  void seenbaredefinition();
92  void seenparamdefinition();
93  void storedefinitionname( iter_t begin, iter_t end );
94  void seentype( iter_t begin, iter_t end );
95  void seensizehint();
96  void seenproperty();
97 
98  rule_t constantdefinition, aliasdefinition, variabledefinition,
99  paramdefinition, baredefinition,
100  vardecl, constdecl, baredecl,
101  valuechange_parsers;
102 
103  TaskContext* context;
104  Service::shared_ptr mstore;
105  ExpressionParser expressionparser;
106  CommonParser& commonparser;
107 
108  int sizehint;
109  boost::shared_ptr<types::TypeInfoRepository> typerepos;
110 
114  void cleanup();
115  public:
126  Service::shared_ptr storage,
127  ExecutionEngine* caller);
128 
133  void clear();
134 
140  void store( Service::shared_ptr other );
141 
148  void load( Service::shared_ptr source );
149 
158  {
159  if ( assigncommands.empty() )
160  return 0;
161  return assigncommands.back();
162  }
163 
164  std::vector<base::ActionInterface*> assignCommands()
165  {
166  return assigncommands;
167  }
168 
170  {
171  if ( definedvalues.empty() )
172  return 0;
173  return definedvalues.back();
174  }
175 
176  std::vector<base::AttributeBase*> definedValues()
177  {
178  return definedvalues;
179  }
180 
181  std::string lastDefinedName()
182  {
183  if ( definednames.empty() )
184  return "";
185  return definednames.back();
186  }
187 
188  std::vector<std::string> definedNames()
189  {
190  return definednames;
191  }
192 
193  std::vector<std::string> allDefinedNames()
194  {
195  return alldefinednames;
196  }
197 
203  rule_t& parser();
204 
211 
218 
225 
232 
239 
244  void reset();
245  };
246 }}
247 
248 #endif
rule_t & parser()
Returns the full parser, as it is used most.
std::vector< base::AttributeBase * > definedValues()
void load(Service::shared_ptr source)
Loads all defined names from a service.
rule_t & aliasDefinitionParser()
The parser that parses alias definitions.
rule_t & bareDefinitionParser()
The parser that parses a bare variable definition.
std::vector< std::string > allDefinedNames()
void reset()
Completely clear all data and erase all parsed definitions from the taskcontext given in the construc...
base::ActionInterface * assignCommand()
This base::ActionInterface holds the command assigning a value to a variable that should be included ...
This class contains some very common parser definitions.
An execution engine serialises (executes one after the other) the execution of all commands...
boost::shared_ptr< Service > shared_ptr
Definition: Service.hpp:101
void store(Service::shared_ptr other)
Store allDefinedNames() in a service.
How we parse: this parser works like a stack-based RPN calculator.
An attribute is a minimalistic, named placeholder for data.
Based on the software pattern &#39;command&#39;, this interface allows execution of action objects...
std::vector< std::string > definedNames()
rule< scanner_t > rule_t
A class for representing a user type, and which can build instances of that type. ...
Definition: TypeInfo.hpp:66
This class is responsible for parsing constant definitions, variable definitions, variable change ins...
void clear()
Clear assignCommands(), definedValues() and definedNames().
rule_t & paramDefinitionParser()
The parser that parses state context parameter definitions.
rule_t & constantDefinitionParser()
the parser that parses definitions of constants.
rule_t & variableDefinitionParser()
the parser that parses variable definitions, don&#39;t forget to check assignCommand after a variable def...
base::AttributeBase * lastDefinedValue()
The TaskContext is the C++ representation of an Orocos component.
Definition: TaskContext.hpp:93
std::vector< base::ActionInterface * > assignCommands()
Contains TaskContext, Activity, OperationCaller, Operation, Property, InputPort, OutputPort, Attribute.
Definition: Activity.cpp:51
our_pos_iter_t iter_t
ValueChangeParser(TaskContext *tc, CommonParser &cp, Service::shared_ptr storage, ExecutionEngine *caller)
Create a ValueChangeParser which operates and stores values in a task.