ITK  4.1.0
Insight Segmentation and Registration Toolkit
itkTestingHashImageFilter.h
Go to the documentation of this file.
00001 /*=========================================================================
00002  *
00003  *  Copyright Insight Software Consortium
00004  *
00005  *  Licensed under the Apache License, Version 2.0 (the "License");
00006  *  you may not use this file except in compliance with the License.
00007  *  You may obtain a copy of the License at
00008  *
00009  *         http://www.apache.org/licenses/LICENSE-2.0.txt
00010  *
00011  *  Unless required by applicable law or agreed to in writing, software
00012  *  distributed under the License is distributed on an "AS IS" BASIS,
00013  *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00014  *  See the License for the specific language governing permissions and
00015  *  limitations under the License.
00016  *
00017  *=========================================================================*/
00018 #ifndef __itkTestingHashImageFilter_h
00019 #define __itkTestingHashImageFilter_h
00020 
00021 
00022 #include "itkSimpleDataObjectDecorator.h"
00023 #include "itkInPlaceImageFilter.h"
00024 
00025 namespace itk
00026 {
00027 namespace Testing
00028 {
00029 
00044 template < class TImageType >
00045 class ITK_EXPORT HashImageFilter:
00046     public InPlaceImageFilter< TImageType, TImageType >
00047 {
00048 public:
00050   typedef HashImageFilter                              Self;
00051   typedef InPlaceImageFilter< TImageType, TImageType > Superclass;
00052   typedef SmartPointer< Self >                         Pointer;
00053   typedef SmartPointer< const Self >                   ConstPointer;
00054 
00055   typedef typename TImageType::RegionType RegionType;
00056 
00058   itkNewMacro(Self);
00059 
00061   itkTypeMacro(HashImageFilter, CastImageFilter);
00062 
00064   typedef typename DataObject::Pointer DataObjectPointer;
00065 
00067   typedef SimpleDataObjectDecorator< std::string >  HashObjectType;
00068 
00070   std::string GetHash() const
00071   { return this->GetHashOutput()->Get(); }
00072   HashObjectType* GetHashOutput()
00073   { return static_cast< HashObjectType *>( this->ProcessObject::GetOutput(1) ); }
00074   const HashObjectType* GetHashOutput() const
00075   { return static_cast<const HashObjectType *>( this->ProcessObject::GetOutput(1) ); }
00077 
00080   typedef ProcessObject::DataObjectPointerArraySizeType DataObjectPointerArraySizeType;
00081   using Superclass::MakeOutput;
00082   virtual DataObjectPointer MakeOutput(DataObjectPointerArraySizeType idx);
00083 
00084   enum  HashFunction { MD5 };
00085 
00089   itkSetMacro( HashFunction, HashFunction );
00090   itkGetMacro( HashFunction, HashFunction );
00092 
00093 protected:
00094 
00095   HashImageFilter();
00096 
00097   // virtual ~HashImageFilter(); // implementation not needed
00098 
00099   virtual void PrintSelf(std::ostream & os, Indent indent) const;
00100 
00101   virtual
00102     void ThreadedGenerateData(const typename Superclass::OutputImageRegionType &,
00103                               ThreadIdType) {}
00104 
00105   // See superclass for doxygen documentation
00106   //
00107   // This method is to do work after the superclass potential threaded
00108   // copy.
00109   void AfterThreadedGenerateData();
00110 
00111   // See superclass for doxygen documentation
00112   //
00113   // Override since the filter produces all of its output
00114   void EnlargeOutputRequestedRegion(DataObject *data);
00115 
00116 private:
00117   HashImageFilter(const Self &); //purposely not implemented
00118   void operator=(const Self &);  //purposely not implemented
00119 
00120   HashFunction m_HashFunction;
00121 };
00122 
00123 } // end namespace Testing
00124 } // end namespace itk
00125 
00126 
00127 #include "itkTestingHashImageFilter.hxx"
00128 
00129 #endif // __itkTestingHashImageFilter_h
00130