ITK  5.2.0
Insight Toolkit
itkTestingHashImageFilter.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 itkTestingHashImageFilter_h
19 #define itkTestingHashImageFilter_h
20 
21 
23 #include "itkInPlaceImageFilter.h"
24 
25 namespace itk
26 {
27 namespace Testing
28 {
34 {
35 public:
40  enum class HashFunction : uint8_t
41  {
42  MD5
43  };
44 };
45 // Define how to print enumeration
46 extern std::ostream &
47 operator<<(std::ostream & out, HashImageFilterEnums::HashFunction value);
48 
64 template <typename TImageType>
65 class ITK_TEMPLATE_EXPORT HashImageFilter : public InPlaceImageFilter<TImageType, TImageType>
66 {
67 public:
68  ITK_DISALLOW_COPY_AND_MOVE(HashImageFilter);
69 
75 
77 
79  itkNewMacro(Self);
80 
82  itkTypeMacro(HashImageFilter, CastImageFilter);
83 
86 
89 
91  std::string
92  GetHash() const
93  {
94  return this->GetHashOutput()->Get();
95  }
96  HashObjectType *
98  {
99  return static_cast<HashObjectType *>(this->ProcessObject::GetOutput(1));
100  }
101  const HashObjectType *
103  {
104  return static_cast<const HashObjectType *>(this->ProcessObject::GetOutput(1));
105  }
107 
111  using Superclass::MakeOutput;
113  MakeOutput(DataObjectPointerArraySizeType idx) override;
114 
116 #if !defined(ITK_LEGACY_REMOVE)
117 
118  static constexpr HashFunctionEnum MD5 = HashFunctionEnum::MD5;
119 #endif
120 
124  itkSetEnumMacro(HashFunction, HashFunctionEnum);
125  itkGetMacro(HashFunction, HashFunctionEnum);
127 
128 protected:
129  HashImageFilter();
130 
131  // virtual ~HashImageFilter(); // implementation not needed
132 
133  void
134  PrintSelf(std::ostream & os, Indent indent) const override;
135 
137  void
138  ThreadedGenerateData(const typename Superclass::OutputImageRegionType &, ThreadIdType) override
139  {}
140  void
141  DynamicThreadedGenerateData(const typename Superclass::OutputImageRegionType &) override
142  {}
144 
145  // See superclass for doxygen documentation
146  //
147  // This method is to do work after the superclass potential threaded
148  // copy.
149  void
150  AfterThreadedGenerateData() override;
151 
152  // See superclass for doxygen documentation
153  //
154  // Override since the filter produces all of its output
155  void
156  EnlargeOutputRequestedRegion(DataObject * data) override;
157 
158 private:
159  HashFunctionEnum m_HashFunction{ HashFunctionEnum::MD5 };
160 };
161 
162 } // end namespace Testing
163 } // end namespace itk
164 
165 
166 #include "itkTestingHashImageFilter.hxx"
167 
168 #endif // itkTestingHashImageFilter_h
itk::Testing::HashImageFilter
Generates a md5 hash string from an image.
Definition: itkTestingHashImageFilter.h:65
itk::SimpleDataObjectDecorator
Decorates any "simple" data type (data types without smart pointers) with a DataObject API.
Definition: itkSimpleDataObjectDecorator.h:66
itk::uint8_t
::uint8_t uint8_t
Definition: itkIntTypes.h:29
itk::CastImageFilter
Casts input pixels to output pixel type.
Definition: itkCastImageFilter.h:104
itk::Testing::HashImageFilter::GetHashOutput
const HashObjectType * GetHashOutput() const
Definition: itkTestingHashImageFilter.h:102
itk::InPlaceImageFilter
Base class for filters that take an image as input and overwrite that image as the output.
Definition: itkInPlaceImageFilter.h:77
itk::ProcessObject::GetOutput
DataObject * GetOutput(const DataObjectIdentifierType &key)
HashFunction
itk::SmartPointer< Self >
itk::Indent
Control indentation during Print() invocation.
Definition: itkIndent.h:49
itk::ProcessObject::DataObjectPointerArraySizeType
DataObjectPointerArray::size_type DataObjectPointerArraySizeType
Definition: itkProcessObject.h:193
itk::Testing::HashImageFilterEnums::HashFunction::MD5
itk::Testing::HashImageFilter::ThreadedGenerateData
void ThreadedGenerateData(const typename Superclass::OutputImageRegionType &, ThreadIdType) override
Definition: itkTestingHashImageFilter.h:138
itk::ThreadIdType
unsigned int ThreadIdType
Definition: itkIntTypes.h:99
itk::LightObject
Light weight base class for most itk classes.
Definition: itkLightObject.h:59
itk::Testing::HashImageFilter::GetHashOutput
HashObjectType * GetHashOutput()
Definition: itkTestingHashImageFilter.h:97
itk::GTest::TypedefsAndConstructors::Dimension2::RegionType
ImageBaseType::RegionType RegionType
Definition: itkGTestTypedefsAndConstructors.h:54
itk::Testing::HashImageFilterEnums::HashFunction
HashFunction
Definition: itkTestingHashImageFilter.h:40
itk::Testing::HashImageFilter::DynamicThreadedGenerateData
void DynamicThreadedGenerateData(const typename Superclass::OutputImageRegionType &) override
Definition: itkTestingHashImageFilter.h:141
itk::Testing::operator<<
std::ostream & operator<<(std::ostream &out, const ExtractSliceImageFilterEnums::TestExtractSliceImageFilterCollapseStrategy value)
itk::Testing::HashImageFilterEnums
Enum classes for HashImageFilter.
Definition: itkTestingHashImageFilter.h:33
itk
The "itk" namespace contains all Insight Segmentation and Registration Toolkit (ITK) classes....
Definition: itkAnnulusOperator.h:24
itkInPlaceImageFilter.h
itkSimpleDataObjectDecorator.h
itk::Testing::HashImageFilter::GetHash
std::string GetHash() const
Definition: itkTestingHashImageFilter.h:92
itk::DataObject::Pointer
SmartPointer< Self > Pointer
Definition: itkDataObject.h:301
itk::Testing::HashImageFilter::RegionType
typename TImageType::RegionType RegionType
Definition: itkTestingHashImageFilter.h:76
itk::DataObject
Base class for all data objects in ITK.
Definition: itkDataObject.h:293