Predicates.h
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 ArmarXCore
19  * @author Raphael Grimm ( raphael dot grimm at kit dot edu)
20  * @date 2017
21  * @copyright http://www.gnu.org/licenses/gpl-2.0.txt
22  * GNU General Public License
23  */
24 
25 #pragma once
26 
27 #include <type_traits>
28 #include <tuple>
29 
30 namespace armarx
31 {
32  template<class T>
34  {
35  EqualPredicate(T t) : t {std::move(t)} {}
36  bool operator()(const T& other)
37  {
38  return t == other;
39  }
40  const T t;
41  };
42  template<class T>
44  {
45  return EqualPredicate<T> {std::move(t)};
46  }
47 
48  template<class T>
50  {
51  UnequalPredicate(T t) : t {std::move(t)} {}
52  bool operator()(const T& other)
53  {
54  return t != other;
55  }
56  const T t;
57  };
58  template<class T>
60  {
61  return UnequalPredicate<T> {std::move(t)};
62  }
63 
64  template<class T>
66  {
67  LessPredicate(T t) : t {std::move(t)} {}
68  bool operator()(const T& other)
69  {
70  return other < t;
71  }
72  const T t;
73  };
74  template<class T>
76  {
77  return LessPredicate<T> {std::move(t)};
78  }
79 
80  template<class T>
82  {
83  GreaterPredicate(T t) : t {std::move(t)} {}
84  bool operator()(const T& other)
85  {
86  return other > t;
87  }
88  const T t;
89  };
90  template<class T>
92  {
93  return GreaterPredicate<T> {std::move(t)};
94  }
95 
96  template<class T>
98  {
99  LessEqualPredicate(T t) : t {std::move(t)} {}
100  bool operator()(const T& other)
101  {
102  return other <= t;
103  }
104  const T t;
105  };
106  template<class T>
108  {
109  return LessEqualPredicate<T> {std::move(t)};
110  }
111 
112  template<class T>
114  {
115  GreaterEqualPredicate(T t) : t {std::move(t)} {}
116  bool operator()(const T& other)
117  {
118  return other >= t;
119  }
120  const T t;
121  };
122  template<class T>
124  {
125  return GreaterEqualPredicate<T> {std::move(t)};
126  }
127 }
armarx::EqualPredicate::EqualPredicate
EqualPredicate(T t)
Definition: Predicates.h:35
armarx::greaterEqualPredicate
GreaterEqualPredicate< T > greaterEqualPredicate(T t)
Definition: Predicates.h:123
armarx::GreaterPredicate::t
const T t
Definition: Predicates.h:88
armarx::LessPredicate::operator()
bool operator()(const T &other)
Definition: Predicates.h:68
armarx::GreaterEqualPredicate::operator()
bool operator()(const T &other)
Definition: Predicates.h:116
armarx::GreaterPredicate
Definition: Predicates.h:81
armarx::lessPredicate
LessPredicate< T > lessPredicate(T t)
Definition: Predicates.h:75
armarx::LessEqualPredicate
Definition: Predicates.h:97
armarx::equalPredicate
EqualPredicate< T > equalPredicate(T t)
Definition: Predicates.h:43
armarx::LessEqualPredicate::operator()
bool operator()(const T &other)
Definition: Predicates.h:100
armarx::lessEqualPredicate
LessEqualPredicate< T > lessEqualPredicate(T t)
Definition: Predicates.h:107
armarx::LessPredicate::LessPredicate
LessPredicate(T t)
Definition: Predicates.h:67
armarx::GreaterPredicate::operator()
bool operator()(const T &other)
Definition: Predicates.h:84
armarx::UnequalPredicate::UnequalPredicate
UnequalPredicate(T t)
Definition: Predicates.h:51
armarx::EqualPredicate::operator()
bool operator()(const T &other)
Definition: Predicates.h:36
armarx::LessPredicate
Definition: Predicates.h:65
armarx::UnequalPredicate
Definition: Predicates.h:49
armarx::GreaterPredicate::GreaterPredicate
GreaterPredicate(T t)
Definition: Predicates.h:83
armarx::GreaterEqualPredicate
Definition: Predicates.h:113
armarx::greaterPredicate
GreaterPredicate< T > greaterPredicate(T t)
Definition: Predicates.h:91
armarx::GreaterEqualPredicate::t
const T t
Definition: Predicates.h:120
armarx::LessEqualPredicate::t
const T t
Definition: Predicates.h:104
armarx::LessEqualPredicate::LessEqualPredicate
LessEqualPredicate(T t)
Definition: Predicates.h:99
armarx::unequalPredicate
UnequalPredicate< T > unequalPredicate(T t)
Definition: Predicates.h:59
armarx::EqualPredicate
Definition: Predicates.h:33
armarx::GreaterEqualPredicate::GreaterEqualPredicate
GreaterEqualPredicate(T t)
Definition: Predicates.h:115
T
float T
Definition: UnscentedKalmanFilterTest.cpp:35
armarx::LessPredicate::t
const T t
Definition: Predicates.h:72
armarx::EqualPredicate::t
const T t
Definition: Predicates.h:40
armarx::UnequalPredicate::t
const T t
Definition: Predicates.h:56
armarx
This file offers overloads of toIce() and fromIce() functions for STL container types.
Definition: ArmarXTimeserver.cpp:28
armarx::UnequalPredicate::operator()
bool operator()(const T &other)
Definition: Predicates.h:52