VTK
|
00001 /*========================================================================= 00002 00003 Program: Visualization Toolkit 00004 Module: vtkHeap.h 00005 00006 Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen 00007 All rights reserved. 00008 See Copyright.txt or http://www.kitware.com/Copyright.htm for details. 00009 00010 This software is distributed WITHOUT ANY WARRANTY; without even 00011 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 00012 PURPOSE. See the above copyright notice for more information. 00013 00014 =========================================================================*/ 00044 #ifndef __vtkHeap_h 00045 #define __vtkHeap_h 00046 00047 #include "vtkCommonMiscModule.h" // For export macro 00048 #include "vtkObject.h" 00049 00050 class vtkHeapBlock; //forward declaration 00051 00052 class VTKCOMMONMISC_EXPORT vtkHeap : public vtkObject 00053 { 00054 public: 00055 static vtkHeap *New(); 00056 vtkTypeMacro(vtkHeap,vtkObject); 00057 void PrintSelf(ostream& os, vtkIndent indent); 00058 00060 void* AllocateMemory(size_t n); 00061 00063 00065 virtual void SetBlockSize(size_t); 00066 virtual size_t GetBlockSize() { return this->BlockSize;}; 00068 00070 00071 vtkGetMacro(NumberOfBlocks,int); 00072 vtkGetMacro(NumberOfAllocations,int); 00074 00078 void Reset(); 00079 00081 char* StringDup(const char* str); 00082 00083 protected: 00084 vtkHeap(); 00085 ~vtkHeap(); 00086 00087 void Add(size_t blockSize); 00088 void CleanAll(); 00089 vtkHeapBlock* DeleteAndNext(); 00090 00091 size_t BlockSize; 00092 int NumberOfAllocations; 00093 int NumberOfBlocks; 00094 int Alignment; 00095 00096 // Manage the blocks 00097 vtkHeapBlock* First; 00098 vtkHeapBlock* Last; 00099 vtkHeapBlock* Current; 00100 // Manage the memory in the block 00101 size_t Position; //the position in the Current block 00102 00103 private: 00104 vtkHeap(const vtkHeap&); // Not implemented. 00105 void operator=(const vtkHeap&); // Not implemented. 00106 }; 00107 00108 #endif