ITK  5.4.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 
23 namespace itk
24 {
25 namespace Functor
26 {
27 
33 template <typename TInput1, typename TInput2 = TInput1, typename TOutput = TInput1>
34 class ITK_TEMPLATE_EXPORT AND
35 {
36 public:
37  bool
38  operator==(const AND &) const
39  {
40  return true;
41  }
42 
43  ITK_UNEQUAL_OPERATOR_MEMBER_FUNCTION(AND);
44 
45  inline TOutput
46  operator()(const TInput1 & A, const TInput2 & B) const
47  {
48  return static_cast<TOutput>(A & B);
49  }
50 };
51 
57 template <typename TInput1, typename TInput2 = TInput1, typename TOutput = TInput1>
58 class ITK_TEMPLATE_EXPORT OR
59 {
60 public:
61  bool
62  operator==(const OR &) const
63  {
64  return true;
65  }
66 
67  ITK_UNEQUAL_OPERATOR_MEMBER_FUNCTION(OR);
68 
69  inline TOutput
70  operator()(const TInput1 & A, const TInput2 & B) const
71  {
72  return static_cast<TOutput>(A | B);
73  }
74 };
75 
81 template <typename TInput1, typename TInput2 = TInput1, typename TOutput = TInput1>
82 class ITK_TEMPLATE_EXPORT XOR
83 {
84 public:
85  bool
86  operator==(const XOR &) const
87  {
88  return true;
89  }
90 
91  ITK_UNEQUAL_OPERATOR_MEMBER_FUNCTION(XOR);
92 
93  inline TOutput
94  operator()(const TInput1 & A, const TInput2 & B) const
95  {
96  return static_cast<TOutput>(A ^ B);
97  }
98 };
99 
105 template <class TInput, class TOutput>
107 {
108 public:
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
itk::Functor::XOR
bitwise XOR functor
Definition: itkBitwiseOpsFunctors.h:82
itk::Functor::AND::operator==
bool operator==(const AND &) const
Definition: itkBitwiseOpsFunctors.h:38
itk::Functor::OR::operator==
bool operator==(const OR &) const
Definition: itkBitwiseOpsFunctors.h:62
itk::Functor::AND::operator()
TOutput operator()(const TInput1 &A, const TInput2 &B) const
Definition: itkBitwiseOpsFunctors.h:46
itk::Functor::AND
bitwise AND functor
Definition: itkBitwiseOpsFunctors.h:34
itk::Functor::BitwiseNot::ITK_UNEQUAL_OPERATOR_MEMBER_FUNCTION
ITK_UNEQUAL_OPERATOR_MEMBER_FUNCTION(BitwiseNot)
itkMacro.h
itk::Functor::XOR::operator()
TOutput operator()(const TInput1 &A, const TInput2 &B) const
Definition: itkBitwiseOpsFunctors.h:94
itk::Functor::BitwiseNot
Performs the C++ unary bitwise NOT operator.
Definition: itkBitwiseOpsFunctors.h:106
itk
The "itk" namespace contains all Insight Segmentation and Registration Toolkit (ITK) classes....
Definition: itkAnnulusOperator.h:24
itk::Functor::BitwiseNot::operator()
TOutput operator()(const TInput &A) const
Definition: itkBitwiseOpsFunctors.h:121
itk::Functor::OR::operator()
TOutput operator()(const TInput1 &A, const TInput2 &B) const
Definition: itkBitwiseOpsFunctors.h:70
itk::Functor::OR
bitwise OR functor
Definition: itkBitwiseOpsFunctors.h:58
itk::Functor::BitwiseNot::operator==
bool operator==(const BitwiseNot &) const
Definition: itkBitwiseOpsFunctors.h:113
itk::Functor::XOR::operator==
bool operator==(const XOR &) const
Definition: itkBitwiseOpsFunctors.h:86