StateGraphParser.hpp
Go to the documentation of this file.
1 /***************************************************************************
2  tag: Peter Soetens Thu Apr 22 20:40:59 CEST 2004 StateGraphParser.hpp
3 
4  StateGraphParser.hpp - description
5  -------------------
6  begin : Thu April 22 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 EXECUTION_STATE_PARSER_HPP
39 #define EXECUTION_STATE_PARSER_HPP
40 
41 #include "parser-types.hpp"
42 
43 #include <map>
44 #include <string>
45 #include <boost/function.hpp>
46 #include <boost/shared_ptr.hpp>
47 #include "../internal/DataSource.hpp"
48 namespace RTT { namespace scripting
49 {
50 
62  {
63  // Our task we are parsing in :
65  // The task that will execute it:
67  // The Service of the current StateMachine
68  boost::shared_ptr<StateMachineService> curobject ;
72  // offset relative to StateMachine text.
73  int ln_offset;
74 
75  typedef boost::shared_ptr<ParsedStateMachine> ParsedStateMachinePtr;
76  typedef std::map<std::string, ParsedStateMachinePtr> machinenamemap_t;
77  typedef std::map<std::string, base::AttributeBase*> machineparams_t;
78  typedef std::map<std::string, base::DataSourceBase::shared_ptr> machineparamvalues_t;
79  typedef std::map<std::string, StateDescription*> machinestatesmap_t;
80  typedef std::map<std::string, StateMachineBuilder*> machinebuilders_t;
81 
82  machinenamemap_t rootmachines;
83  machinebuilders_t machinebuilders;
84  ParsedStateMachinePtr curtemplate;
85  std::vector<base::ActionInterface*> paraminitcommands;
86  std::vector<base::ActionInterface*> varinitcommands;
87  ParsedStateMachinePtr curinstantiatedmachine;
89  std::string curinstmachinename;
90  machineparamvalues_t curinstmachineparams;
92  std::string curmachinename;
98  boost::shared_ptr<ProgramInterface> transProgram;
100  boost::shared_ptr<ProgramInterface> elseProgram;
102 #if 0
103  std::string curscvcmachinename;
104  std::string curscvcparamname;
105 #endif
106 
110  int rank;
111  bool isroot;
112  unsigned int selectln;
113 
114  std::vector<base::DataSourceBase::shared_ptr> evargs;
115  std::string evname;
116  std::map<std::string,ConditionCache*> cur_port_events;
117  std::map<std::string,ConditionCache*> global_port_events;
118 
157 
164 
165  void clear();
166 
167  void seeninitialstate();
168  void seenfinalstate();
169  void statedef( iter_t s, iter_t f);
170  void seenstateend();
171 
172  void inprogram( const std::string& name );
173  void seenentry();
174  void seenexit();
175  void seenhandle();
176  void seenrun();
177  boost::shared_ptr<ProgramInterface> finishProgram();
178 
179  void seencondition();
180  void seenendcondition();
181  void seentransprog();
182  void seenelseprog();
183  void seenelse();
184  void noselect();
185  void seenselect( iter_t s, iter_t f);
186  void doselect(const std::string& name);
187  void seenprecondition();
188  void seeneventname(iter_t s, iter_t f);
189  void seeneventtrans();
190  void seeneventargs();
191 
192  void seenstatemachinename( iter_t begin, iter_t end );
193  void saveText( iter_t begin, iter_t end );
196  void seenstatemachineend();
198 
199  void inpreconditions();
200  void seenpreconditions();
201 
202  void seenmachinetypename( iter_t begin, iter_t end );
203  void seeninstmachinename( iter_t begin, iter_t end );
205  void seenmachineinstargumentname( iter_t begin, iter_t end );
207 
208  void seenmachinevariable();
209  void seenmachineparam();
210 
211 #if 0
212  void seenscvcsubMachinename( iter_t begin, iter_t end );
213  void seenscvcparamname( iter_t begin, iter_t end );
214 #endif
215  public:
216  StateGraphParser( iter_t& positer, TaskContext* tc, ExecutionEngine* caller, CommonParser* cp );
218 
219  // tries to parse, returns the instantiated root machines. On all
220  // returned machines setName() will have been called with the
221  // correct name.
222  // will throw an file_parse_exception on error
223  std::vector<ParsedStateMachinePtr> parse( iter_t& begin, iter_t end );
224 
231  rule_t& parser();
236  ParsedStateMachinePtr getParserResult();
237 
243  void storeOffset();
244  };
245 }}
246 
247 #endif
unsigned int selectln
are we instantiating a rootmachine ?
void seenmachineinstargumentname(iter_t begin, iter_t end)
void saveText(iter_t begin, iter_t end)
std::map< std::string, base::DataSourceBase::shared_ptr > machineparamvalues_t
This interface represents the concept of a condition which can be evaluated and return true or false...
This class represents a state with all actions stored in an external program.
StateGraphParser(iter_t &positer, TaskContext *tc, ExecutionEngine *caller, CommonParser *cp)
void statedef(iter_t s, iter_t f)
A Parser for Orocos Program Scripts.
This class contains some very common parser definitions.
machineparamvalues_t curinstmachineparams
std::map< std::string, base::AttributeBase * > machineparams_t
void doselect(const std::string &name)
std::map< std::string, StateDescription * > machinestatesmap_t
std::map< std::string, ConditionCache * > global_port_events
ParsedStateMachinePtr curinstantiatedmachine
position_iterator< our_iterator_t > our_pos_iter_t
ParsedStateMachinePtr getParserResult()
std::vector< base::ActionInterface * > varinitcommands
void inprogram(const std::string &name)
boost::shared_ptr< Service > ServicePtr
Definition: rtt-fwd.hpp:86
rule< scanner_t > rule_t
StateMachineBuilder * curmachinebuilder
void seenmachinetypename(iter_t begin, iter_t end)
std::vector< base::DataSourceBase::shared_ptr > evargs
store line number of select&#39;s &#39;if&#39; statement.
boost::shared_ptr< StateMachineService > curobject
boost::shared_ptr< ProgramInterface > transProgram
std::map< std::string, ConditionCache * > cur_port_events
std::map< std::string, ParsedStateMachinePtr > machinenamemap_t
boost::shared_ptr< ProgramInterface > elseProgram
void seeneventname(iter_t s, iter_t f)
void seenstatemachinename(iter_t begin, iter_t end)
std::map< std::string, StateMachineBuilder * > machinebuilders_t
Contains TaskContext, Activity, OperationCaller, Operation, Property, InputPort, OutputPort, Attribute.
Definition: Activity.cpp:53
std::vector< base::ActionInterface * > paraminitcommands
our_pos_iter_t iter_t
void seeninstmachinename(iter_t begin, iter_t end)
boost::shared_ptr< ProgramInterface > finishProgram()
boost::shared_ptr< ParsedStateMachine > ParsedStateMachinePtr
std::vector< ParsedStateMachinePtr > parse(iter_t &begin, iter_t end)
void seenselect(iter_t s, iter_t f)


rtt
Author(s): RTT Developers
autogenerated on Tue Jun 25 2019 19:33:36