ConditionParser.cpp
Go to the documentation of this file.
1 /***************************************************************************
2  tag: Peter Soetens Mon May 10 19:10:37 CEST 2004 ConditionParser.cxx
3 
4  ConditionParser.cxx - description
5  -------------------
6  begin : Mon May 10 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  * 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 #include "parser-debug.hpp"
39 #include "parse_exception.hpp"
40 #ifdef ORO_PRAGMA_INTERFACE
41 #pragma implementation
42 #endif
43 #include "ConditionParser.hpp"
44 
45 #include "ConditionDuration.hpp"
46 #include "ConditionTrue.hpp"
47 #include "ConditionFalse.hpp"
49 #include "ConditionComposite.hpp"
50 
51 #include <boost/bind.hpp>
52 
53 #include "TryCommand.hpp"
54 
55 namespace RTT
56 {
57  using namespace detail;
58  using boost::bind;
59 
60 
61 
63  : ds_bool( 0 ), context( c ), commonparser(cp), expressionparser( c, caller, cp )
64  {
65  BOOST_SPIRIT_DEBUG_RULE( condition );
66 
71  condition =
73  bind( &ConditionParser::seenexpression, this ) ];
74  }
75 
77  {
78  // not strictly needed because its a smart_ptr
79  ds_bool = 0;
80  }
81 
83  {
84  }
85 
87  {
88  // get the datasource parsed by the ExpressionParser..
92 
93  // The reference count is stored in the DataSource itself !
94  // so the ref cnt information is not lost in this cast
95  ds_bool =
96  dynamic_cast<DataSource<bool>*>( mcurdata.get() );
97  if ( ds_bool )
98  {
99  mcurdata = 0;
100  }
101  else
102  {
103  // we only want boolean expressions..
105  "Attempt to use a non-boolean value as a condition." );
106  }
107  }
108 
110  {
111  // wrap the datasource in a ConditionBoolDataSource..
112  return new ConditionBoolDataSource( ds_bool.get() );
113  }
114 
118  std::pair<ActionInterface*,ConditionInterface*> ConditionParser::getParseResultAsCommand()
119  {
120  EvalCommand* ec = new EvalCommand( ds_bool );
121  EvalCommandResult* ecr = new EvalCommandResult( ec->cache() );
122  return std::make_pair( ec, ecr );
123  //return std::pair<ActionInterface*,ConditionInterface*>(0,0);
124  }
125 }
std::pair< base::ActionInterface *, ConditionInterface * > getParseResultAsCommand()
virtual result_t get() const =0
ConditionInterface * getParseResult()
ConditionParser(TaskContext *context, ExecutionEngine *caller, CommonParser &cp)
This interface represents the concept of a condition which can be evaluated and return true or false...
This class contains some very common parser definitions.
internal::DataSource< bool >::shared_ptr ds_bool
base::DataSourceBase::shared_ptr getResult()
internal::AssignableDataSource< bool >::shared_ptr cache()
Definition: TryCommand.cpp:152
boost::intrusive_ptr< DataSourceBase > shared_ptr
Contains TaskContext, Activity, OperationCaller, Operation, Property, InputPort, OutputPort, Attribute.
Definition: Activity.cpp:53


rtt
Author(s): RTT Developers
autogenerated on Fri Oct 25 2019 03:59:32