ConditionComposite.hpp
Go to the documentation of this file.
1 /***************************************************************************
2  tag: Peter Soetens Mon Jan 19 14:11:21 CET 2004 ConditionComposite.hpp
3 
4  ConditionComposite.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 CONDITIONCOMPOSITE_HPP
39 #define CONDITIONCOMPOSITE_HPP
40 
41 #include "rtt-scripting-config.h"
42 #include "ConditionInterface.hpp"
43 
44 namespace RTT { namespace scripting {
45 
46 
50  class RTT_SCRIPTING_API ConditionBinaryCompositeAND
51  : public ConditionInterface
52  {
55  public:
62  : lhs( l ), rhs( r )
63  {
64  }
65 
66  virtual ConditionInterface* clone() const
67  {
68  return new ConditionBinaryCompositeAND( lhs->clone(), rhs->clone() );
69  }
70 
71  ConditionBinaryCompositeAND* copy( std::map<const base::DataSourceBase*, base::DataSourceBase*>& alreadyCloned ) const {
72  return new ConditionBinaryCompositeAND(lhs->copy(alreadyCloned),rhs->copy(alreadyCloned));
73  }
74 
76  delete lhs;
77  delete rhs;
78  }
79 
80  virtual bool evaluate() {
81  if ( lhs->evaluate() )
82  if ( rhs->evaluate() )
83  return true;
84  return false;
85  }
86 
87  virtual void reset()
88  {
89  lhs->reset();
90  rhs->reset();
91  }
92  };
93 
94  /*
95  * Compose an 'OR' function of two Conditions.
96  */
97  class RTT_SCRIPTING_API ConditionBinaryCompositeOR
98  : public ConditionInterface
99  {
102  public:
109  : lhs( l ), rhs( r )
110  {
111  }
112 
113  virtual ConditionInterface* clone() const
114  {
115  return new ConditionBinaryCompositeOR( lhs->clone(), rhs->clone() );
116  }
117 
118  ConditionBinaryCompositeOR* copy( std::map<const base::DataSourceBase*, base::DataSourceBase*>& alreadyCloned ) const {
119  return new ConditionBinaryCompositeOR(lhs->copy(alreadyCloned),rhs->copy(alreadyCloned));
120  }
121 
123  delete lhs;
124  delete rhs;
125  }
126 
127  virtual bool evaluate() {
128  if ( lhs->evaluate() )
129  return true;
130  if ( rhs->evaluate() )
131  return true;
132  return false;
133  }
134 
135  virtual void reset()
136  {
137  lhs->reset();
138  rhs->reset();
139  }
140  };
141 
142  class RTT_SCRIPTING_API ConditionCompositeNOT
143  : public ConditionInterface
144  {
146  public:
148  : cond( c )
149  {
150  }
152  bool evaluate();
153  ConditionCompositeNOT* clone() const;
154  ConditionCompositeNOT* copy( std::map<const base::DataSourceBase*, base::DataSourceBase*>& alreadyCloned ) const;
155  void reset();
156  };
157 }}
158 
159 #endif
This interface represents the concept of a condition which can be evaluated and return true or false...
virtual ConditionInterface * clone() const
virtual ConditionInterface * clone() const =0
ConditionBinaryCompositeAND * copy(std::map< const base::DataSourceBase *, base::DataSourceBase * > &alreadyCloned) const
virtual ConditionInterface * copy(std::map< const base::DataSourceBase *, base::DataSourceBase * > &alreadyCloned) const
virtual ConditionInterface * clone() const
ConditionBinaryCompositeOR(ConditionInterface *l, ConditionInterface *r)
virtual bool evaluate()
Evaluate the Condition and return the outcome.
virtual bool evaluate()
Evaluate the Condition and return the outcome.
virtual bool evaluate()=0
Evaluate the Condition and return the outcome.
ConditionBinaryCompositeAND(ConditionInterface *l, ConditionInterface *r)
Contains TaskContext, Activity, OperationCaller, Operation, Property, InputPort, OutputPort, Attribute.
Definition: Activity.cpp:53
ConditionBinaryCompositeOR * copy(std::map< const base::DataSourceBase *, base::DataSourceBase * > &alreadyCloned) const


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