Jpp test-rotations-old
the software that should make you happy
Loading...
Searching...
No Matches
JBool.hh
Go to the documentation of this file.
1#ifndef __JLANG__JBOOL__
2#define __JLANG__JBOOL__
3
4
5/**
6 * \author mdejong
7 */
8
9namespace JLANG {}
10namespace JPP { using namespace JLANG; }
11
12namespace JLANG {
13
14
15 /**
16 * Auxiliary template class for type bool.
17 * This class can be used for boolean expressions at compile time.
18 */
19 template<bool __value__>
20 struct JBool
21 {
22 /**
23 * Type definition of bool value.
24 */
26
27
28 /**
29 * Default construcor.
30 */
32 {}
33
34
35 /**
36 * Value.
37 */
38 static const bool value = __value__;
39
40
41 /**
42 * Type conversion operator.
43 *
44 * \return value
45 */
46 operator bool() const
47 {
48 return value;
49 }
50
51
52 /**
53 * Make logical NOT.
54 *
55 * \return logical NOT
56 */
58 {
59 return JBool<!value>();
60 }
61
62
63 /**
64 * Make logical EQUALS.
65 *
66 * \return logical EQUALS
67 */
68 template<bool option>
73
74
75 /**
76 * Make logical EQUALS.
77 *
78 * \param object value
79 * \return logical EQUALS
80 */
81 template<bool option>
83 {
85 }
86
87
88 /**
89 * Make logical AND.
90 *
91 * \return logical AND
92 */
93 template<bool option>
95 {
97 }
98
99
100 /**
101 * Make logical AND.
102 *
103 * \param object value
104 * \return logical AND
105 */
106 template<bool option>
108 {
110 }
111
112
113 /**
114 * Make logical OR.
115 *
116 * \return logical OR
117 */
118 template<bool option>
120 {
121 return JBool<value || option>();
122 }
123
124
125 /**
126 * Make logical OR.
127 *
128 * \param object value
129 * \return logical OR
130 */
131 template<bool option>
133 {
135 }
136
137
138 /**
139 * Make logical XOR.
140 *
141 * \return logical XOR
142 */
143 template<bool option>
145 {
146 return JBool<value != option>();
147 }
148
149
150 /**
151 * Make logical XOR.
152 *
153 * \param object value
154 * \return logical XOR
155 */
156 template<bool option>
158 {
160 }
161
162
163 /**
164 * Make logical SWITCH.
165 * If value is true, select first, else select second.
166 *
167 * \return logical SWITCH
168 */
169 template<bool __first__, bool __second__>
170 static JBool<(value && __first__) || (!value && __second__)> c_switch()
171 {
173 }
174
175
176 /**
177 * Make logical SWITCH.
178 * If value is true, select first, else select second.
179 *
180 * \param first first value
181 * \param second second value
182 * \return logical SWITCH
183 */
184 template<bool __first__, bool __second__>
185 static JBool<(value && __first__) || (!value && __second__)> c_switch(const JBool<__first__>& first,
186 const JBool<__second__>& second)
187 {
189 }
190 };
191
192
193 /**
194 * Make logical NOT.
195 *
196 * \param value value
197 * \return logical NOT
198 */
199 template<bool __value__>
201 {
202 return value.c_not();
203 }
204
205
206 /**
207 * Make logical EQUALS.
208 *
209 * \param first first value
210 * \param second second value
211 * \return logical EQUALS
212 */
213 template<bool __first__, bool __second__>
215 const JBool<__second__>& second)
216 {
217 return first.c_equals(second);
218 }
219
220
221 /**
222 * Make logical AND.
223 *
224 * \param first first value
225 * \param second second value
226 * \return logical AND
227 */
228 template<bool __first__, bool __second__>
230 const JBool<__second__>& second)
231 {
232 return first.c_and(second);
233 }
234
235
236 /**
237 * Make logical OR.
238 *
239 * \param first first value
240 * \param second second value
241 * \return logical OR
242 */
243 template<bool __first__, bool __second__>
245 const JBool<__second__>& second)
246 {
247 return first.c_or(second);
248 }
249
250
251 /**
252 * Make logical XOR.
253 *
254 * \param first first value
255 * \param second second value
256 * \return logical XOR
257 */
258 template<bool __first__, bool __second__>
260 const JBool<__second__>& second)
261 {
262 return first.c_xor(second);
263 }
264
265
266 typedef JBool<true> JTRUE; //!< True type
267 typedef JBool<false> JFALSE; //!< False type
268
269 static const JTRUE JTrue_t; //!< True value
270 static const JFALSE JFalse_t; //!< False value
271
272
273 /**
274 * Type definition of logical EQUALS.
275 */
276 template<class JFirst_t, class JSecond_t>
277 struct EQUALS;
278
279 /**
280 * Template specialisation for logical EQUALS.
281 */
282 template<bool first, bool second>
283 struct EQUALS< JBool<first>, JBool<second> > :
284 public JBool<first == second>
285 {};
286
287
288 /**
289 * Type definition of logical NOT.
290 */
291 template<class T>
292 struct NOT;
293
294 /**
295 * Template specialisation for logical NOT.
296 */
297 template<bool __value__>
298 struct NOT< JBool<__value__> > :
299 public JBool<!__value__>
300 {};
301
302
303 /**
304 * Type definition of logical AND.
305 */
306 template<class JFirst_t, class JSecond_t>
307 struct AND;
308
309 /**
310 * Template specialisation for logical AND.
311 */
312 template<bool first, bool second>
313 struct AND< JBool<first>, JBool<second> > :
314 public JBool<first && second>
315 {};
316
317
318 /**
319 * Type definition of logical OR.
320 */
321 template<class JFirst_t, class JSecond_t>
322 struct OR;
323
324 /**
325 * Template specialisation for logical OR.
326 */
327 template<bool first, bool second>
328 struct OR< JBool<first>, JBool<second> > :
329 public JBool<first || second>
330 {};
331
332
333 /**
334 * Type definition of logical XOR.
335 */
336 template<class JFirst_t, class JSecond_t>
337 struct XOR;
338
339 /**
340 * Template specialisation for logical XOR.
341 */
342 template<bool first, bool second>
343 struct XOR< JBool<first>, JBool<second> > :
344 public JBool<first != second>
345 {};
346}
347
348#endif
Auxiliary classes and methods for language specific functionality.
static JBool<!__value__ > c_not(const JBool< __value__ > &value)
Make logical NOT.
Definition JBool.hh:200
static const JFALSE JFalse_t
False value.
Definition JBool.hh:270
JBool< __first__==__second__ > c_and(const JBool< __first__ > &first, const JBool< __second__ > &second)
Make logical AND.
Definition JBool.hh:229
JBool< __first__==__second__ > c_equals(const JBool< __first__ > &first, const JBool< __second__ > &second)
Make logical EQUALS.
Definition JBool.hh:214
static const JTRUE JTrue_t
True value.
Definition JBool.hh:269
JBool< false > JFALSE
False type.
Definition JBool.hh:267
JBool< __first__==__second__ > c_or(const JBool< __first__ > &first, const JBool< __second__ > &second)
Make logical OR.
Definition JBool.hh:244
JBool< true > JTRUE
True type.
Definition JBool.hh:266
JBool< __first__==__second__ > c_xor(const JBool< __first__ > &first, const JBool< __second__ > &second)
Make logical XOR.
Definition JBool.hh:259
This name space includes all other name spaces (except KM3NETDAQ, KM3NET and ANTARES).
Type definition of logical AND.
Definition JBool.hh:307
Type definition of logical EQUALS.
Definition JBool.hh:277
Auxiliary template class for type bool.
Definition JBool.hh:21
static JBool<!value > c_not()
Make logical NOT.
Definition JBool.hh:57
static JBool< value||option > c_or(const JBool< option > &object)
Make logical OR.
Definition JBool.hh:132
static JBool< value &&option > c_and()
Make logical AND.
Definition JBool.hh:94
static JBool< value==option > c_equals()
Make logical EQUALS.
Definition JBool.hh:69
static JBool<(value &&__first__)||(!value &&__second__)> c_switch()
Make logical SWITCH.
Definition JBool.hh:170
static JBool< value||option > c_or()
Make logical OR.
Definition JBool.hh:119
static JBool< value !=option > c_xor(const JBool< option > &object)
Make logical XOR.
Definition JBool.hh:157
static JBool< value !=option > c_xor()
Make logical XOR.
Definition JBool.hh:144
static JBool< value==option > c_equals(const JBool< option > &object)
Make logical EQUALS.
Definition JBool.hh:82
JBool< __value__ > bool_type
Type definition of bool value.
Definition JBool.hh:25
JBool()
Default construcor.
Definition JBool.hh:31
static JBool<(value &&__first__)||(!value &&__second__)> c_switch(const JBool< __first__ > &first, const JBool< __second__ > &second)
Make logical SWITCH.
Definition JBool.hh:185
static JBool< value &&option > c_and(const JBool< option > &object)
Make logical AND.
Definition JBool.hh:107
static const bool value
Value.
Definition JBool.hh:38
Type definition of logical NOT.
Definition JBool.hh:292
Type definition of logical OR.
Definition JBool.hh:322
Type definition of logical XOR.
Definition JBool.hh:337