ITK  4.13.0
Insight Segmentation and Registration Toolkit
itkTestingHashImageFilter.h
Go to the documentation of this file.
1 /*=========================================================================
2  *
3  * Copyright Insight Software Consortium
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 {
29 
44 template < typename TImageType >
45 class ITK_TEMPLATE_EXPORT HashImageFilter:
46  public InPlaceImageFilter< TImageType, TImageType >
47 {
48 public:
54 
55  typedef typename TImageType::RegionType RegionType;
56 
58  itkNewMacro(Self);
59 
62 
64  typedef typename DataObject::Pointer DataObjectPointer;
65 
68 
70  std::string GetHash() const
71  { return this->GetHashOutput()->Get(); }
73  { return static_cast< HashObjectType *>( this->ProcessObject::GetOutput(1) ); }
75  { return static_cast<const HashObjectType *>( this->ProcessObject::GetOutput(1) ); }
77 
81  using Superclass::MakeOutput;
82  virtual DataObjectPointer MakeOutput(DataObjectPointerArraySizeType idx) ITK_OVERRIDE;
83 
84  enum HashFunction { MD5 };
85 
89  itkSetMacro( HashFunction, HashFunction );
90  itkGetMacro( HashFunction, HashFunction );
92 
93 protected:
94 
96 
97  // virtual ~HashImageFilter(); // implementation not needed
98 
99  virtual void PrintSelf(std::ostream & os, Indent indent) const ITK_OVERRIDE;
100 
101  virtual
102  void ThreadedGenerateData(const typename Superclass::OutputImageRegionType &,
103  ThreadIdType) ITK_OVERRIDE {}
104 
105  // See superclass for doxygen documentation
106  //
107  // This method is to do work after the superclass potential threaded
108  // copy.
109  void AfterThreadedGenerateData() ITK_OVERRIDE;
110 
111  // See superclass for doxygen documentation
112  //
113  // Override since the filter produces all of its output
114  void EnlargeOutputRequestedRegion(DataObject *data) ITK_OVERRIDE;
115 
116 private:
117  ITK_DISALLOW_COPY_AND_ASSIGN(HashImageFilter);
118 
119  HashFunction m_HashFunction;
120 };
121 
122 } // end namespace Testing
123 } // end namespace itk
124 
125 
126 #include "itkTestingHashImageFilter.hxx"
127 
128 #endif // itkTestingHashImageFilter_h
Light weight base class for most itk classes.
Decorates any &quot;simple&quot; data type (data types without smart pointers) with a DataObject API...
DataObjectPointerArray::size_type DataObjectPointerArraySizeType
SmartPointer< const Self > ConstPointer
SimpleDataObjectDecorator< std::string > HashObjectType
Generates a md5 hash string from an image.
const HashObjectType * GetHashOutput() const
unsigned int ThreadIdType
Definition: itkIntTypes.h:159
InPlaceImageFilter< TImageType, TImageType > Superclass
Control indentation during Print() invocation.
Definition: itkIndent.h:49
virtual void ThreadedGenerateData(const typename Superclass::OutputImageRegionType &, ThreadIdType) override
ProcessObject::DataObjectPointerArraySizeType DataObjectPointerArraySizeType
Base class for filters that take an image as input and overwrite that image as the output...
Base class for all data objects in ITK.
Casts input pixels to output pixel type.
DataObject * GetOutput(const DataObjectIdentifierType &key)