SimpleITK  1.0.1
itkHashImageFilter.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 itkHashImageFilter_h
19 #define itkHashImageFilter_h
20 
21 
24 #include "itkCastImageFilter.h"
25 #include "itkByteSwapper.h"
26 
27 
28 #include "Ancillary/hl_md5.h"
29 #include "Ancillary/hl_sha1.h"
30 
31 namespace itk {
32 
42 template < class TImageType >
44  public CastImageFilter< TImageType, TImageType >
45 {
46 public:
52 
53  typedef typename TImageType::RegionType RegionType;
54 
56  itkNewMacro(Self);
57 
60 
63 
66 
68  std::string GetHash() const
69  { return this->GetHashOutput()->Get(); }
70  HashObjectType* GetHashOutput()
71  { return static_cast< HashObjectType *>( this->ProcessObject::GetOutput(1) ); }
72  const HashObjectType* GetHashOutput() const
73  { return static_cast<const HashObjectType *>( this->ProcessObject::GetOutput(1) ); }
74 
75  enum HashFunction { SHA1, MD5 };
76 
80 
85  virtual DataObjectPointer MakeOutput(DataObjectPointerArraySizeType idx) ITK_OVERRIDE;
86 
87 protected:
88 
90 
91  // virtual ~HashImageFilter(); // implementation not needed
92 
93  virtual void PrintSelf(std::ostream & os, Indent indent) const ITK_OVERRIDE;
94 
95  // See superclass for doxygen documentation
96  //
97  // This method is to do work after the superclass potential threaded
98  // copy.
99  void AfterThreadedGenerateData() ITK_OVERRIDE;
100 
101  // See superclass for doxygen documentation
102  //
103  // Override since the filter produces all of its output
104  void EnlargeOutputRequestedRegion(DataObject *data) ITK_OVERRIDE;
105 
106 private:
107  HashImageFilter(const Self &); //purposely not implemented
108  void operator=(const Self &); //purposely not implemented
109 
110 
112 };
113 
114 
115 } // end namespace itk
116 
117 
118 #include "itkHashImageFilter.hxx"
119 
120 #endif // itkHashImageFilter_h
SmartPointer< Self > Pointer
SmartPointer< const Self > ConstPointer
DataObjectPointerArray::size_type DataObjectPointerArraySizeType
const HashObjectType * GetHashOutput() const
itkTypeMacro(HashImageFilter, CastImageFilter)
TImageType::RegionType RegionType
virtual void PrintSelf(std::ostream &os, Indent indent) const ITK_OVERRIDE
ProcessObject::DataObjectPointer MakeOutput(ProcessObject::DataObjectPointerArraySizeType idx) override
itkSetMacro(HashFunction, HashFunction)
virtual DataObjectPointer MakeOutput(DataObjectPointerArraySizeType idx) ITK_OVERRIDE
itkGetMacro(HashFunction, HashFunction)
void EnlargeOutputRequestedRegion(DataObject *data) ITK_OVERRIDE
HashObjectType * GetHashOutput()
ProcessObject::DataObjectPointerArraySizeType DataObjectPointerArraySizeType
SimpleDataObjectDecorator< std::string > HashObjectType
std::string GetHash() const
DataObject::Pointer DataObjectPointer
CastImageFilter< TImageType, TImageType > Superclass
Generates a hash string from an image.
void AfterThreadedGenerateData() ITK_OVERRIDE
DataObject * GetOutput(const DataObjectIdentifierType &key)