CommandFunctors.hpp
Go to the documentation of this file.
1 /***************************************************************************
2  tag: FMTC do nov 2 13:06:11 CET 2006 CommandFunctors.hpp
3 
4  CommandFunctors.hpp - description
5  -------------------
6  begin : do november 02 2006
7  copyright : (C) 2006 FMTC
8  email : peter.soetens@fmtc.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 
39 #ifndef ORO_COMMANDFUNCTORS_HPP
40 #define ORO_COMMANDFUNCTORS_HPP
41 
42 #include <boost/bind.hpp>
43 #include <boost/function.hpp>
44 #include <boost/type_traits/function_traits.hpp>
45 
46 #include "../base/ActionInterface.hpp"
47 #include "ConditionInterface.hpp"
48 
49 namespace RTT
50 {
51  namespace scripting {
52 
58  :public base::ActionInterface
59  {
60  public:
61  typedef boost::function<bool(void)> Function;
62 
63  Function com;
64 
68  CommandFunction(Function impl)
69  : com(impl)
70  {
71  }
72 
73  virtual void readArguments() { }
74 
75  virtual bool execute() { return com(); }
76 
77  virtual CommandFunction* clone() const
78  {
79  return new CommandFunction( com );
80  }
81  };
82 
88  :public ConditionInterface
89  {
90  public:
91  typedef boost::function<bool(void)> Function;
92 
93  Function con;
94  bool minvert;
95 
99  ConditionFunction(Function impl, bool invert=false)
100  : con(impl), minvert(invert)
101  {
102  }
103 
104  virtual bool evaluate() { return con() != minvert; }
105 
106  virtual ConditionFunction* clone() const
107  {
108  return new ConditionFunction( con, minvert );
109  }
110  };
111  }
112 }
113 
114 #endif
virtual ConditionFunction * clone() const
ConditionFunction(Function impl, bool invert=false)
virtual CommandFunction * clone() const
This interface represents the concept of a condition which can be evaluated and return true or false...
boost::function< bool(void)> Function
Based on the software pattern &#39;command&#39;, this interface allows execution of action objects...
boost::function< bool(void)> Function
Contains TaskContext, Activity, OperationCaller, Operation, Property, InputPort, OutputPort, Attribute.
Definition: Activity.cpp:53
virtual bool evaluate()
Evaluate the Condition and return the outcome.


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