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 <tuple>
28#include <type_traits>
29
30namespace armarx
31{
32 template <class T>
34 {
35 EqualPredicate(T t) : t{std::move(t)}
36 {
37 }
38
39 bool
40 operator()(const T& other)
41 {
42 return t == other;
43 }
44
45 const T t;
46 };
47
48 template <class T>
51 {
52 return EqualPredicate<T>{std::move(t)};
53 }
54
55 template <class T>
57 {
59 {
60 }
61
62 bool
63 operator()(const T& other)
64 {
65 return t != other;
66 }
67
68 const T t;
69 };
70
71 template <class T>
74 {
75 return UnequalPredicate<T>{std::move(t)};
76 }
77
78 template <class T>
80 {
81 LessPredicate(T t) : t{std::move(t)}
82 {
83 }
84
85 bool
86 operator()(const T& other)
87 {
88 return other < t;
89 }
90
91 const T t;
92 };
93
94 template <class T>
97 {
98 return LessPredicate<T>{std::move(t)};
99 }
100
101 template <class T>
103 {
105 {
106 }
107
108 bool
109 operator()(const T& other)
110 {
111 return other > t;
112 }
113
114 const T t;
115 };
116
117 template <class T>
120 {
121 return GreaterPredicate<T>{std::move(t)};
122 }
123
124 template <class T>
126 {
128 {
129 }
130
131 bool
132 operator()(const T& other)
133 {
134 return other <= t;
135 }
136
137 const T t;
138 };
139
140 template <class T>
143 {
144 return LessEqualPredicate<T>{std::move(t)};
145 }
146
147 template <class T>
149 {
151 {
152 }
153
154 bool
155 operator()(const T& other)
156 {
157 return other >= t;
158 }
159
160 const T t;
161 };
162
163 template <class T>
166 {
167 return GreaterEqualPredicate<T>{std::move(t)};
168 }
169} // namespace armarx
This file offers overloads of toIce() and fromIce() functions for STL container types.
LessPredicate< T > lessPredicate(T t)
Definition Predicates.h:96
LessEqualPredicate< T > lessEqualPredicate(T t)
Definition Predicates.h:142
UnequalPredicate< T > unequalPredicate(T t)
Definition Predicates.h:73
GreaterPredicate< T > greaterPredicate(T t)
Definition Predicates.h:119
GreaterEqualPredicate< T > greaterEqualPredicate(T t)
Definition Predicates.h:165
EqualPredicate< T > equalPredicate(T t)
Definition Predicates.h:50
bool operator()(const T &other)
Definition Predicates.h:40
bool operator()(const T &other)
Definition Predicates.h:155
bool operator()(const T &other)
Definition Predicates.h:109
bool operator()(const T &other)
Definition Predicates.h:132
bool operator()(const T &other)
Definition Predicates.h:86
bool operator()(const T &other)
Definition Predicates.h:63