ITK  6.0.0
Insight Toolkit
itkBitwiseOpsFunctors.h
Go to the documentation of this file.
1/*=========================================================================
2 *
3 * Copyright NumFOCUS
4 *
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
8 *
9 * https://www.apache.org/licenses/LICENSE-2.0.txt
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 *
17 *=========================================================================*/
18#ifndef itkBitwiseOpsFunctors_h
19#define itkBitwiseOpsFunctors_h
20
21#include "itkMacro.h"
22
23namespace itk
24{
25namespace Functor
26{
27
33template <typename TInput1, typename TInput2 = TInput1, typename TOutput = TInput1>
34class ITK_TEMPLATE_EXPORT AND
35{
36public:
37 bool
38 operator==(const AND &) const
39 {
40 return true;
41 }
42
44
45 inline TOutput
46 operator()(const TInput1 & A, const TInput2 & B) const
47 {
48 return static_cast<TOutput>(A & B);
49 }
50};
51
57template <typename TInput1, typename TInput2 = TInput1, typename TOutput = TInput1>
58class ITK_TEMPLATE_EXPORT OR
59{
60public:
61 bool
62 operator==(const OR &) const
63 {
64 return true;
65 }
66
68
69 inline TOutput
70 operator()(const TInput1 & A, const TInput2 & B) const
71 {
72 return static_cast<TOutput>(A | B);
73 }
74};
75
81template <typename TInput1, typename TInput2 = TInput1, typename TOutput = TInput1>
82class ITK_TEMPLATE_EXPORT XOR
83{
84public:
85 bool
86 operator==(const XOR &) const
87 {
88 return true;
89 }
90
92
93 inline TOutput
94 operator()(const TInput1 & A, const TInput2 & B) const
95 {
96 return static_cast<TOutput>(A ^ B);
97 }
98};
99
105template <class TInput, class TOutput>
107{
108public:
109 // Use default copy, assigned and destructor
110 // BitwiseNot() {} default constructor OK
111
112 bool
113 operator==(const BitwiseNot &) const
114 {
115 return true;
116 }
117
119
120 inline TOutput
121 operator()(const TInput & A) const
122 {
123 return static_cast<TOutput>(~A);
124 }
125};
126} // namespace Functor
127} // namespace itk
128
129#endif
bitwise AND functor
TOutput operator()(const TInput1 &A, const TInput2 &B) const
bool operator==(const AND &) const
ITK_UNEQUAL_OPERATOR_MEMBER_FUNCTION(AND)
Performs the C++ unary bitwise NOT operator.
bool operator==(const BitwiseNot &) const
ITK_UNEQUAL_OPERATOR_MEMBER_FUNCTION(BitwiseNot)
TOutput operator()(const TInput &A) const
bitwise OR functor
TOutput operator()(const TInput1 &A, const TInput2 &B) const
bool operator==(const OR &) const
ITK_UNEQUAL_OPERATOR_MEMBER_FUNCTION(OR)
bitwise XOR functor
ITK_UNEQUAL_OPERATOR_MEMBER_FUNCTION(XOR)
bool operator==(const XOR &) const
TOutput operator()(const TInput1 &A, const TInput2 &B) const
The "itk" namespace contains all Insight Segmentation and Registration Toolkit (ITK) classes....