Orocos Real-Time Toolkit  2.9.0
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  std::vector<scripting::ConditionInterface*> conditions;
66 
67  // the defined values...
68  // This list is cleared in cleanup().
69  std::vector<base::AttributeBase*> definedvalues;
70 
71  // the parsed variable or constant or alias or param
72  // definition name.
73  // This list is cleared in cleanup().
74  std::vector<std::string> definednames;
75 
76  // A list of all the names stored in \a context.
77  // this list is used to remove them when reset() is
78  // called.
79  std::vector<std::string> alldefinednames;
80 
81  // the name of the value of which we're currently parsing the
82  // definition or assignment..
83  std::string valuename;
84 
85  // A types::TypeInfo of the type that was specified. We use it to get
86  // hold of a Constant or a TaskVariable or ...
87  types::TypeInfo* type;
88 
89  void seenconstantdefinition();
90  void seenaliasdefinition();
91  void seenvariabledefinition();
92  void seenbaredefinition();
93  void seenparamdefinition();
94  void storedefinitionname( iter_t begin, iter_t end );
95  void seentype( iter_t begin, iter_t end );
96  void seensizehint();
97  void seenproperty();
98 
99  rule_t constantdefinition, aliasdefinition, variabledefinition,
100  paramdefinition, baredefinition,
101  vardecl, constdecl, baredecl,
102  valuechange_parsers;
103 
104  TaskContext* context;
105  Service::shared_ptr mstore;
106  ExpressionParser expressionparser;
107  CommonParser& commonparser;
108 
109  int sizehint;
110  boost::shared_ptr<types::TypeInfoRepository> typerepos;
111 
115  void cleanup();
116  public:
127  Service::shared_ptr storage,
128  ExecutionEngine* caller);
129 
134  void clear();
135 
141  void store( Service::shared_ptr other );
142 
149  void load( Service::shared_ptr source );
150 
159  {
160  if ( assigncommands.empty() )
161  return 0;
162  return assigncommands.back();
163  }
164 
165  std::vector<base::ActionInterface*> assignCommands()
166  {
167  return assigncommands;
168  }
169 
170  std::vector<scripting::ConditionInterface*> assignConditions()
171  {
172  return conditions;
173  }
174 
176  {
177  if ( definedvalues.empty() )
178  return 0;
179  return definedvalues.back();
180  }
181 
182  std::vector<base::AttributeBase*> definedValues()
183  {
184  return definedvalues;
185  }
186 
187  std::string lastDefinedName()
188  {
189  if ( definednames.empty() )
190  return "";
191  return definednames.back();
192  }
193 
194  std::vector<std::string> definedNames()
195  {
196  return definednames;
197  }
198 
199  std::vector<std::string> allDefinedNames()
200  {
201  return alldefinednames;
202  }
203 
209  rule_t& parser();
210 
217 
224 
231 
238 
245 
250  void reset();
251  };
252 }}
253 
254 #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.
std::vector< scripting::ConditionInterface * > assignConditions()
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:67
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:52
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.