Main Page   Groups   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members   Concepts

itkImportImageContainer.h

Go to the documentation of this file.
00001 /*=========================================================================
00002 
00003   Program:   Insight Segmentation & Registration Toolkit
00004   Module:    $RCSfile: itkImportImageContainer.h,v $
00005   Language:  C++
00006   Date:      $Date: 2009-04-25 12:24:09 $
00007   Version:   $Revision: 1.24 $
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      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 Capacity(void) const
00091     { return (unsigned long) m_Capacity; }
00092 
00094   unsigned long Size(void) const
00095     { return (unsigned long) m_Size; }
00096 
00109   void Reserve(ElementIdentifier num);
00110 
00117   void Squeeze(void);
00118 
00120   void Initialize(void);
00121 
00122 
00132   itkSetMacro(ContainerManageMemory,bool);
00133   itkGetConstMacro(ContainerManageMemory,bool);
00134   itkBooleanMacro(ContainerManageMemory);
00136 
00137 
00138 protected:
00139   ImportImageContainer();
00140   virtual ~ImportImageContainer();
00141 
00145   void PrintSelf(std::ostream& os, Indent indent) const;
00146 
00147   virtual TElement* AllocateElements(ElementIdentifier size) const;
00148   virtual void DeallocateManagedMemory();
00149 
00150   /* Set the m_Size member that represents the number of elements
00151    * currently stored in the container. Use this function with great
00152    * care since it only changes the m_Size member and not the actual size
00153    * of the import pointer m_ImportPointer. It should typically
00154    * be used only to override AllocateElements and
00155    * DeallocateManagedMemory. */
00156   itkSetMacro(Size,TElementIdentifier);
00157    
00158   /* Set the m_Capacity member that represents the capacity of
00159    * the current container. Use this function with great care
00160    * since it only changes the m_Capacity member and not the actual
00161    * capacity of the import pointer m_ImportPointer. It should typically
00162    * be used only to override AllocateElements and
00163    * DeallocateManagedMemory. */
00164   itkSetMacro(Capacity,TElementIdentifier);
00165 
00166   
00167   /* Set the m_ImportPointer member. Use this function with great care
00168    * since it only changes the m_ImportPointer member but not the m_Size
00169    * and m_Capacity members. It should typically be used only to override
00170    * AllocateElements and DeallocateManagedMemory. */
00171   void SetImportPointer(TElement *ptr){m_ImportPointer=ptr;}
00172 
00173 private:
00174   ImportImageContainer(const Self&); //purposely not implemented
00175   void operator=(const Self&); //purposely not implemented
00176 
00177   TElement            *m_ImportPointer;
00178   TElementIdentifier   m_Size;
00179   TElementIdentifier   m_Capacity;
00180   bool                 m_ContainerManageMemory;
00181 };
00182 
00183 } // end namespace itk
00184 
00185 // Define instantiation macro for this template.
00186 #define ITK_TEMPLATE_ImportImageContainer(_, EXPORT, x, y) namespace itk { \
00187   _(2(class EXPORT ImportImageContainer< ITK_TEMPLATE_2 x >)) \
00188   namespace Templates { typedef ImportImageContainer< ITK_TEMPLATE_2 x > ImportImageContainer##y; } \
00189   }
00190 
00191 #if ITK_TEMPLATE_EXPLICIT
00192 # include "Templates/itkImportImageContainer+-.h"
00193 #endif
00194 
00195 #if ITK_TEMPLATE_TXX
00196 # include "itkImportImageContainer.txx"
00197 #endif
00198 
00199 #endif
00200 

Generated at Mon Jul 12 2010 18:49:01 for ITK by doxygen 1.7.1 written by Dimitri van Heesch, © 1997-2000