00001 /*========================================================================= 00002 00003 Program: Insight Segmentation & Registration Toolkit 00004 Module: $RCSfile: itkAutoPointerDataObjectDecorator.h,v $ 00005 Language: C++ 00006 Date: $Date: 2006-03-16 11:43:45 $ 00007 Version: $Revision: 1.4 $ 00008 00009 Copyright (c) Insight Software Consortium. All rights reserved. 00010 See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details. 00011 00012 Portions of this code are covered under the VTK copyright. 00013 See VTKCopyright.txt or http://www.kitware.com/VTKCopyright.htm for details. 00014 00015 This software is distributed WITHOUT ANY WARRANTY; without even 00016 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 00017 PURPOSE. See the above copyright notices for more information. 00018 00019 =========================================================================*/ 00020 #ifndef __itkAutoPointerDataObjectDecorator_h 00021 #define __itkAutoPointerDataObjectDecorator_h 00022 00023 #include <memory> 00024 #include "itkDataObject.h" 00025 00026 namespace itk 00027 { 00028 00029 00052 template<class T> 00053 class ITK_EXPORT AutoPointerDataObjectDecorator : public DataObject 00054 { 00055 public: 00057 typedef AutoPointerDataObjectDecorator Self; 00058 typedef DataObject Superclass; 00059 typedef SmartPointer<Self> Pointer; 00060 typedef SmartPointer<const Self> ConstPointer; 00061 00063 typedef T ComponentType; 00064 typedef std::auto_ptr<T> ComponentPointer; 00065 00067 itkNewMacro(Self); 00068 00070 itkTypeMacro(AutoPointerDataObjectDecorator, DataObject); 00071 00073 virtual void Set(T* val); 00074 00076 virtual T* Get() { return m_Component.get(); } 00077 virtual const T* Get() const { return m_Component.get(); } 00079 00080 protected: 00081 AutoPointerDataObjectDecorator(); 00082 ~AutoPointerDataObjectDecorator(); 00083 virtual void PrintSelf(std::ostream& os, Indent indent) const; 00084 00085 protected: 00086 00087 private: 00088 AutoPointerDataObjectDecorator(const Self&); //purposely not implemented 00089 void operator=(const Self&); //purposely not implemented 00090 00091 ComponentPointer m_Component; 00092 }; 00093 00094 } // end namespace itk 00095 00096 #ifndef ITK_MANUAL_INSTANTIATION 00097 #include "itkAutoPointerDataObjectDecorator.txx" 00098 #endif 00099 00100 #endif 00101