ITK  5.3.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  * http://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  AND() = default;
38  ~AND() = default;
39  bool
40  operator==(const AND &) const
41  {
42  return true;
43  }
45 
46  ITK_UNEQUAL_OPERATOR_MEMBER_FUNCTION(AND);
47 
48  inline TOutput
49  operator()(const TInput1 & A, const TInput2 & B) const
50  {
51  return static_cast<TOutput>(A & B);
52  }
53 };
54 
60 template <typename TInput1, typename TInput2 = TInput1, typename TOutput = TInput1>
61 class ITK_TEMPLATE_EXPORT OR
62 {
63 public:
64  OR() = default;
65  ~OR() = default;
66  bool
67  operator==(const OR &) const
68  {
69  return true;
70  }
72 
73  ITK_UNEQUAL_OPERATOR_MEMBER_FUNCTION(OR);
74 
75  inline TOutput
76  operator()(const TInput1 & A, const TInput2 & B) const
77  {
78  return static_cast<TOutput>(A | B);
79  }
80 };
81 
87 template <typename TInput1, typename TInput2 = TInput1, typename TOutput = TInput1>
88 class ITK_TEMPLATE_EXPORT XOR
89 {
90 public:
91  XOR() = default;
92  ~XOR() = default;
93  bool
94  operator==(const XOR &) const
95  {
96  return true;
97  }
99 
100  ITK_UNEQUAL_OPERATOR_MEMBER_FUNCTION(XOR);
101 
102  inline TOutput
103  operator()(const TInput1 & A, const TInput2 & B) const
104  {
105  return static_cast<TOutput>(A ^ B);
106  }
107 };
108 
114 template <class TInput, class TOutput>
116 {
117 public:
118  // Use default copy, assigned and destructor
119  // BitwiseNot() {} default constructor OK
120 
121  bool
122  operator==(const BitwiseNot &) const
123  {
124  return true;
125  }
126 
128 
129  inline TOutput
130  operator()(const TInput & A) const
131  {
132  return static_cast<TOutput>(~A);
133  }
134 };
135 } // namespace Functor
136 } // namespace itk
137 
138 #endif
itk::Functor::XOR
bitwise XOR fucntor
Definition: itkBitwiseOpsFunctors.h:88
itk::Functor::AND::operator==
bool operator==(const AND &) const
Definition: itkBitwiseOpsFunctors.h:40
itk::Functor::OR::operator==
bool operator==(const OR &) const
Definition: itkBitwiseOpsFunctors.h:67
itk::Functor::AND::operator()
TOutput operator()(const TInput1 &A, const TInput2 &B) const
Definition: itkBitwiseOpsFunctors.h:49
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:103
itk::Functor::BitwiseNot
Performs the C++ unary bitwise NOT operator.
Definition: itkBitwiseOpsFunctors.h:115
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:130
itk::Functor::OR::operator()
TOutput operator()(const TInput1 &A, const TInput2 &B) const
Definition: itkBitwiseOpsFunctors.h:76
itk::Functor::OR
bitwise OR functor
Definition: itkBitwiseOpsFunctors.h:61
itk::Functor::BitwiseNot::operator==
bool operator==(const BitwiseNot &) const
Definition: itkBitwiseOpsFunctors.h:122
itk::Functor::XOR::operator==
bool operator==(const XOR &) const
Definition: itkBitwiseOpsFunctors.h:94