VTK
vtkHeap.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Program: Visualization Toolkit
4  Module: vtkHeap.h
5 
6  Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
7  All rights reserved.
8  See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
9 
10  This software is distributed WITHOUT ANY WARRANTY; without even
11  the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
12  PURPOSE. See the above copyright notice for more information.
13 
14 =========================================================================*/
44 #ifndef __vtkHeap_h
45 #define __vtkHeap_h
46 
47 #include "vtkObject.h"
48 
49 class vtkHeapBlock; //forward declaration
50 
52 {
53 public:
54  static vtkHeap *New();
55  vtkTypeMacro(vtkHeap,vtkObject);
56  void PrintSelf(ostream& os, vtkIndent indent);
57 
59  void* AllocateMemory(size_t n);
60 
62 
64  virtual void SetBlockSize(size_t);
65  virtual size_t GetBlockSize() { return this->BlockSize;};
67 
69 
70  vtkGetMacro(NumberOfBlocks,int);
71  vtkGetMacro(NumberOfAllocations,int);
73 
77  void Reset();
78 
80  char* StringDup(const char* str);
81 
82 protected:
83  vtkHeap();
84  ~vtkHeap();
85 
86  void Add(size_t blockSize);
87  void CleanAll();
88  vtkHeapBlock* DeleteAndNext();
89 
90  size_t BlockSize;
93  int Alignment;
94 
95  // Manage the blocks
96  vtkHeapBlock* First;
97  vtkHeapBlock* Last;
98  vtkHeapBlock* Current;
99  // Manage the memory in the block
100  size_t Position; //the position in the Current block
101 
102 private:
103  vtkHeap(const vtkHeap&); // Not implemented.
104  void operator=(const vtkHeap&); // Not implemented.
105 };
106 
107 #endif