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

itkObjectStore.h

Go to the documentation of this file.
00001 /*========================================================================= 00002 00003 Program: Insight Segmentation & Registration Toolkit 00004 Module: $RCSfile: itkObjectStore.h,v $ 00005 Language: C++ 00006 Date: $Date: 2003/09/10 14:29:19 $ 00007 Version: $Revision: 1.3 $ 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 __itkObjectStore_h 00018 #define __itkObjectStore_h 00019 00020 #include "itkObjectFactory.h" 00021 #include "itkObject.h" 00022 #include <vector> 00023 00024 namespace itk { 00025 00059 template < class TObjectType > 00060 class ITK_EXPORT ObjectStore : public Object 00061 { 00062 public: 00064 typedef ObjectStore Self; 00065 typedef Object Superclass; 00066 typedef SmartPointer<Self> Pointer; 00067 typedef SmartPointer<const Self> ConstPointer; 00068 00070 itkNewMacro(Self); 00071 00073 itkTypeMacro(ObjectStore, Object); 00074 00076 typedef TObjectType ObjectType; 00077 00079 typedef std::vector<ObjectType *> FreeListType; 00080 00082 typedef enum {LINEAR_GROWTH = 0, EXPONENTIAL_GROWTH = 1} GrowthStrategyType; 00083 00085 ObjectType *Borrow(); 00086 00090 void Return(ObjectType *p); 00091 00094 itkGetMacro(Size, ::size_t); 00095 00099 void Reserve(::size_t n); 00100 00103 void Squeeze(); 00104 00106 void Clear(); 00107 00109 itkSetMacro(LinearGrowthSize, ::size_t); 00110 itkGetMacro(LinearGrowthSize, ::size_t); 00111 00113 itkSetMacro(GrowthStrategy, GrowthStrategyType); 00114 itkGetMacro(GrowthStrategy, GrowthStrategyType); 00115 00117 void SetGrowthStrategyToExponential() 00118 { this->SetGrowthStrategy(EXPONENTIAL_GROWTH); } 00119 00121 void SetGrowthStrategyToLinear() 00122 { this->SetGrowthStrategy(LINEAR_GROWTH); } 00123 00124 protected: 00125 ObjectStore(); 00126 ~ObjectStore(); 00127 virtual void PrintSelf(std::ostream& os, Indent indent) const; 00128 00130 ::size_t GetGrowthSize(); 00131 00132 struct MemoryBlock 00133 { 00134 MemoryBlock(): Size(0), Begin(0) {} 00135 00136 MemoryBlock(::size_t n) : Size(n) 00137 { Begin = new ObjectType[n]; } 00138 00139 ~MemoryBlock() { } // Purposely does *not* free memory 00140 00141 void Delete() 00142 { if (Begin !=0) delete[] Begin; } 00143 00144 ObjectType *Begin; 00145 ::size_t Size; 00146 }; 00147 00148 private: 00149 ObjectStore(const Self&); //purposely not implemented 00150 void operator=(const Self&); //purposely not implemented 00151 00152 GrowthStrategyType m_GrowthStrategy; 00153 00154 ::size_t m_Size; 00155 ::size_t m_LinearGrowthSize; 00156 00158 FreeListType m_FreeList; 00159 00161 std::vector<MemoryBlock> m_Store; 00162 00163 }; 00164 00165 00166 } // end namespace itk 00167 00168 #ifndef ITK_MANUAL_INSTANTIATION 00169 #include "itkObjectStore.txx" 00170 #endif 00171 00172 #endif

Generated at Sat Mar 31 02:26:40 2007 for ITK by doxygen 1.3.8 written by Dimitri van Heesch, © 1997-2000