00001 /*========================================================================= 00002 00003 Program: Insight Segmentation & Registration Toolkit 00004 Module: $RCSfile: itkImportImageContainer.h,v $ 00005 Language: C++ 00006 Date: $Date: 2002/12/11 18:53:17 $ 00007 Version: $Revision: 1.14 $ 00008 00009 Copyright (c) 2002 Insight Consortium. All rights reserved. 00010 See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details. 00011 00012 This software is distributed WITHOUT ANY WARRANTY; without even 00013 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 00014 PURPOSE. See the above copyright notices for more information. 00015 00016 =========================================================================*/ 00017 #ifndef __itkImportImageContainer_h 00018 #define __itkImportImageContainer_h 00019 00020 #include "itkObject.h" 00021 #include "itkObjectFactory.h" 00022 #include <utility> 00023 00024 namespace itk 00025 { 00026 00044 template <typename TElementIdentifier, typename TElement> 00045 class ImportImageContainer: public Object 00046 { 00047 public: 00049 typedef ImportImageContainer Self; 00050 typedef Object Superclass; 00051 typedef SmartPointer<Self> Pointer; 00052 typedef SmartPointer<const Self> ConstPointer; 00053 00055 typedef TElementIdentifier ElementIdentifier; 00056 typedef TElement Element; 00057 00059 itkNewMacro(Self); 00060 00062 itkTypeMacro(ImportImageContainer, Object); 00063 00065 TElement *GetImportPointer() {return m_ImportPointer;}; 00066 00073 void SetImportPointer(TElement *ptr, TElementIdentifier num, 00074 bool LetContainerManageMemory = false); 00075 00077 TElement & operator[](const ElementIdentifier id) 00078 { return m_ImportPointer[id]; }; 00079 00081 const TElement & operator[](const ElementIdentifier id) const 00082 { return m_ImportPointer[id]; }; 00083 00086 TElement *GetBufferPointer() 00087 { return m_ImportPointer; }; 00088 00090 unsigned long Size(void) const 00091 { return (unsigned long) m_Size; }; 00092 00101 void Reserve(ElementIdentifier num); 00102 00109 void Squeeze(void); 00110 00112 void Initialize(void); 00113 00114 00124 itkSetMacro(ContainerManageMemory,bool); 00125 itkGetMacro(ContainerManageMemory,bool); 00126 itkBooleanMacro(ContainerManageMemory); 00127 00128 00129 protected: 00130 ImportImageContainer(); 00131 virtual ~ImportImageContainer(); 00132 00136 void PrintSelf(std::ostream& os, Indent indent) const; 00137 00138 00139 private: 00140 ImportImageContainer(const Self&); //purposely not implemented 00141 void operator=(const Self&); //purposely not implemented 00142 00143 TElement *m_ImportPointer; 00144 TElementIdentifier m_Size; 00145 TElementIdentifier m_Capacity; 00146 bool m_ContainerManageMemory; 00147 00148 }; 00149 00150 } // end namespace itk 00151 00152 #ifndef ITK_MANUAL_INSTANTIATION 00153 #include "itkImportImageContainer.txx" 00154 #endif 00155 00156 #endif