Term.cpp
Go to the documentation of this file.
1 /*
2 * This file is part of ArmarX.
3 *
4 * Copyright (C) 2011-2016, High Performance Humanoid Technologies (H2T), Karlsruhe Institute of Technology (KIT), all rights reserved.
5 *
6 * ArmarX is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 as
8 * published by the Free Software Foundation.
9 *
10 * ArmarX is distributed in the hope that it will be useful, but
11 * WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
17 *
18 * @package ArmarX::Core
19 * @author Kai Welke (welke _at_ kit _dot_ edu)
20 * @date 2012 Kai Welke
21 * @copyright http://www.gnu.org/licenses/gpl-2.0.txt
22 * GNU General Public License
23 */
24 
27 
28 namespace armarx
29 {
31  {
32  termImpl = nullptr;
33  }
34 
35  Term::Term(const Term& other)
36  {
37  if (other.termImpl)
38  {
39  this->termImpl = TermImplPtr::dynamicCast(other.termImpl->ice_clone());
40  }
41  else
42  {
43  this->termImpl = nullptr;
44  }
45  }
46 
48  {
49  this->termImpl = impl;
50  }
51 
52  Term Term::operator&&(const Term& right) const
53  {
54  if (!this->getImpl())
55  {
56  return right;
57  }
58 
59  Term opAnd;
60  opAnd.termImpl = new OperationAnd(this->getImpl(), right.getImpl());
61 
62  return opAnd;
63  }
64 
65  Term Term::operator||(const Term& right) const
66  {
67  if (!this->getImpl())
68  {
69  return right;
70  }
71 
72  Term opOr;
73  opOr.termImpl = new OperationOr(this->getImpl(), right.getImpl());
74  return opOr;
75  }
76 
77  Term Term::operator!(void) const
78  {
79  if (!this->getImpl())
80  {
81  return *this;
82  }
83 
84  Term opNot;
85  opNot.termImpl = new OperationNot(this->getImpl());
86  return opNot;
87  }
88 
89  Term& Term::operator=(const Term& right)
90  {
91  if (right.getImpl())
92  {
93  this->termImpl = TermImplPtr::dynamicCast(right.getImpl()->ice_clone());
94  }
95  else
96  {
97  this->termImpl = nullptr;
98  }
99 
100  return *this;
101  }
102 
104  {
105  return termImpl;
106  }
107 
108 
109  Literal::Literal(const std::string& dataFieldIdentifierStr, const std::string& checkName, const VarList& checkParameters)
110  {
111  termImpl = new LiteralImpl(dataFieldIdentifierStr, checkName, toParamList(checkParameters));
112  }
113 
114  Literal::Literal(const DataFieldIdentifier& dataFieldIdentifier, const std::string& checkName, const VarList& checkParameters)
115  {
116  termImpl = new LiteralImpl(dataFieldIdentifier, checkName, toParamList(checkParameters));
117  }
118 
119  Literal::Literal(const DataFieldIdentifierPtr& dataFieldIdentifier, const std::string& checkName, const VarList& checkParameters)
120  {
121  termImpl = new LiteralImpl(dataFieldIdentifier, checkName, toParamList(checkParameters));
122  }
123 
124  Literal::Literal(const DatafieldRefBasePtr& datafieldRef, const std::string& checkName, const VarList& checkParameters)
125  {
126  termImpl = new LiteralImpl(datafieldRef, checkName, toParamList(checkParameters));
127  }
128 
130  {
131  return VarList();
132  }
133 
135  {
136  VarList list;
137  list.push_back((param1));
138 
139  return list;
140  }
141 
142  VarList Literal::createParameterList(const Variant& param1, const Variant& param2)
143  {
144  VarList list;
145  list.push_back((param1));
146  list.push_back((param2));
147 
148  return list;
149  }
150 
151  VarList Literal::createParameterList(const Variant& param1, const Variant& param2, const Variant& param3)
152  {
153  VarList list;
154  list.push_back((param1));
155  list.push_back((param2));
156  list.push_back((param3));
157 
158  return list;
159  }
160 
161  ParameterList Literal::toParamList(const VarList& varList) const
162  {
163  ParameterList result;
164 
165  for (const auto& var : varList)
166  {
167  result.push_back(new Variant(var));
168  }
169 
170  return result;
171  }
172 }
armarx::Variant
The Variant class is described here: Variants.
Definition: Variant.h:224
armarx::LiteralImpl
LiteralImpls are the basic elements for defining conditional expressions.
Definition: LiteralImpl.h:59
armarx::Literal::toParamList
ParameterList toParamList(const VarList &varList) const
Definition: Term.cpp:161
list
list(APPEND SOURCES ${QT_RESOURCES}) set(COMPONENT_LIBS ArmarXGui ArmarXCoreObservers ArmarXCoreEigen3Variants PlotterController $
Definition: CMakeLists.txt:49
armarx::Term::operator&&
Term operator&&(const Term &right) const
The logical AND operator.
Definition: Term.cpp:52
armarx::Literal::createParameterList
static VarList createParameterList()
Static helper method to create an empty parameterlist.
Definition: Term.cpp:129
armarx::Term
Definition: Term.h:111
Term.h
armarx::VarList
std::vector< Variant > VarList
Definition: Term.h:198
IceInternal::Handle< TermImpl >
armarx::Literal::Literal
Literal(const std::string &dataFieldIdentifierStr, const std::string &checkName, const VarList &checkParameters=createParameterList())
Construct a literal using a datafieldidentifier as string.
Definition: Term.cpp:109
armarx::OperationOr
Definition: Operations.h:124
armarx::Term::Term
Term()
Construct an empty term.
Definition: Term.cpp:30
armarx::Term::termImpl
TermImplPtr termImpl
Definition: Term.h:194
armarx::OperationAnd
Definition: Operations.h:72
armarx::Term::operator!
Term operator!(void) const
The logical NOT operator.
Definition: Term.cpp:77
armarx::OperationNot
Definition: Operations.h:176
Operations.h
armarx::Term::operator=
Term & operator=(const Term &right)
The assignment operator.
Definition: Term.cpp:89
armarx
This file offers overloads of toIce() and fromIce() functions for STL container types.
Definition: ArmarXTimeserver.cpp:28
armarx::Term::operator||
Term operator||(const Term &right) const
The logical OR operator.
Definition: Term.cpp:65
armarx::DataFieldIdentifier
DataFieldIdentifier provide the basis to identify data field within a distributed ArmarX scenario.
Definition: DataFieldIdentifier.h:48
armarx::Term::getImpl
TermImplPtr getImpl() const
Retrieve term implementation object as used in the ArmarX Framework in order to build distributed exp...
Definition: Term.cpp:103