ITK
4.1.0
Insight Segmentation and Registration Toolkit
|
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 __itkImportImageContainer_h 00019 #define __itkImportImageContainer_h 00020 00021 #include "itkObject.h" 00022 #include "itkObjectFactory.h" 00023 #include <utility> 00024 00025 namespace itk 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 ElementIdentifier Capacity(void) const 00091 { return m_Capacity; } 00092 00094 ElementIdentifier Size(void) const 00095 { return m_Size; } 00096 00109 void Reserve(ElementIdentifier num); 00110 00117 void Squeeze(void); 00118 00120 void Initialize(void); 00121 00131 itkSetMacro(ContainerManageMemory, bool); 00132 itkGetConstMacro(ContainerManageMemory, bool); 00133 itkBooleanMacro(ContainerManageMemory); 00134 protected: 00135 ImportImageContainer(); 00136 virtual ~ImportImageContainer(); 00138 00142 void PrintSelf(std::ostream & os, Indent indent) const; 00143 00144 virtual TElement * AllocateElements(ElementIdentifier size) const; 00145 00146 virtual void DeallocateManagedMemory(); 00147 00148 /* Set the m_Size member that represents the number of elements 00149 * currently stored in the container. Use this function with great 00150 * care since it only changes the m_Size member and not the actual size 00151 * of the import pointer m_ImportPointer. It should typically 00152 * be used only to override AllocateElements and 00153 * DeallocateManagedMemory. */ 00154 itkSetMacro(Size, TElementIdentifier); 00155 00156 /* Set the m_Capacity member that represents the capacity of 00157 * the current container. Use this function with great care 00158 * since it only changes the m_Capacity member and not the actual 00159 * capacity of the import pointer m_ImportPointer. It should typically 00160 * be used only to override AllocateElements and 00161 * DeallocateManagedMemory. */ 00162 itkSetMacro(Capacity, TElementIdentifier); 00163 00164 /* Set the m_ImportPointer member. Use this function with great care 00165 * since it only changes the m_ImportPointer member but not the m_Size 00166 * and m_Capacity members. It should typically be used only to override 00167 * AllocateElements and DeallocateManagedMemory. */ 00168 void SetImportPointer(TElement *ptr){ m_ImportPointer = ptr; } 00169 private: 00170 ImportImageContainer(const Self &); //purposely not implemented 00171 void operator=(const Self &); //purposely not implemented 00172 00173 TElement * m_ImportPointer; 00174 TElementIdentifier m_Size; 00175 TElementIdentifier m_Capacity; 00176 bool m_ContainerManageMemory; 00177 }; 00178 } // end namespace itk 00179 00180 // Define instantiation macro for this template. 00181 #define ITK_TEMPLATE_ImportImageContainer(_, EXPORT, TypeX, TypeY) \ 00182 namespace itk \ 00183 { \ 00184 _( 2 ( class EXPORT ImportImageContainer< ITK_TEMPLATE_2 TypeX > ) ) \ 00185 namespace Templates \ 00186 { \ 00187 typedef ImportImageContainer< ITK_TEMPLATE_2 TypeX > ImportImageContainer##TypeY; \ 00188 } \ 00189 } 00190 00191 #if ITK_TEMPLATE_EXPLICIT 00192 #include "Templates/itkImportImageContainer+-.h" 00193 #endif 00194 00195 #if ITK_TEMPLATE_TXX 00196 #include "itkImportImageContainer.hxx" 00197 #endif 00198 00199 #endif 00200