Main Page | Directories | Class Hierarchy | Alphabetical List | Class List | File List | Class Members | File Members | Related Pages

vtkHeap.h

Go to the documentation of this file.
00001 /*=========================================================================
00002 
00003   Program:   Visualization Toolkit
00004   Module:    $RCSfile: vtkHeap.h,v $
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 =========================================================================*/
00056 #ifndef __vtkHeap_h
00057 #define __vtkHeap_h
00058 
00059 #include "vtkObject.h"
00060 
00061 class vtkHeapBlock; //forward declaration
00062 
00063 class VTK_COMMON_EXPORT vtkHeap : public vtkObject
00064 {
00065 public:
00066   static vtkHeap *New();
00067   vtkTypeRevisionMacro(vtkHeap,vtkObject);
00068   void PrintSelf(ostream& os, vtkIndent indent);
00069 
00071   void* AllocateMemory(size_t n);
00072   
00074 
00076   virtual void SetBlockSize(size_t);
00077   virtual size_t GetBlockSize() { return this->BlockSize;};
00079 
00081 
00082   vtkGetMacro(NumberOfBlocks,int);
00083   vtkGetMacro(NumberOfAllocations,int);
00085 
00089   void Reset();
00090   
00092   char* StringDup(const char* str);
00093 
00094 protected:  
00095   vtkHeap();
00096   ~vtkHeap();
00097 
00098   void Add(size_t blockSize);
00099   void CleanAll();
00100   vtkHeapBlock* DeleteAndNext();
00101 
00102   size_t BlockSize;
00103   int    NumberOfAllocations;
00104   int    NumberOfBlocks;
00105   int    Alignment;
00106 
00107   // Manage the blocks
00108   vtkHeapBlock* First;
00109   vtkHeapBlock* Last;
00110   vtkHeapBlock* Current;
00111   // Manage the memory in the block
00112   size_t Position; //the position in the Current block
00113   
00114 private:
00115   vtkHeap(const vtkHeap&); // Not implemented.
00116   void operator=(const vtkHeap&);  // Not implemented.
00117 };
00118 
00119 #endif