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 "vtkCommonMiscModule.h" // For export macro
48 #include "vtkObject.h"
49 
50 class vtkHeapBlock; //forward declaration
51 
53 {
54 public:
55  static vtkHeap *New();
56  vtkTypeMacro(vtkHeap,vtkObject);
57  void PrintSelf(ostream& os, vtkIndent indent);
58 
60  void* AllocateMemory(size_t n);
61 
63 
65  virtual void SetBlockSize(size_t);
66  virtual size_t GetBlockSize() { return this->BlockSize;};
68 
70 
71  vtkGetMacro(NumberOfBlocks,int);
72  vtkGetMacro(NumberOfAllocations,int);
74 
78  void Reset();
79 
81  char* StringDup(const char* str);
82 
83 protected:
84  vtkHeap();
85  ~vtkHeap();
86 
87  void Add(size_t blockSize);
88  void CleanAll();
89  vtkHeapBlock* DeleteAndNext();
90 
91  size_t BlockSize;
94  size_t Alignment;
95 
96  // Manage the blocks
97  vtkHeapBlock* First;
98  vtkHeapBlock* Last;
99  vtkHeapBlock* Current;
100  // Manage the memory in the block
101  size_t Position; //the position in the Current block
102 
103 private:
104  vtkHeap(const vtkHeap&); // Not implemented.
105  void operator=(const vtkHeap&); // Not implemented.
106 };
107 
108 #endif
int NumberOfBlocks
Definition: vtkHeap.h:93
abstract base class for most VTK objects
Definition: vtkObject.h:61
vtkHeapBlock * Current
Definition: vtkHeap.h:99
vtkHeapBlock * First
Definition: vtkHeap.h:97
#define VTKCOMMONMISC_EXPORT
virtual void PrintSelf(ostream &os, vtkIndent indent)
vtkHeapBlock * Last
Definition: vtkHeap.h:98
a simple class to control print indentation
Definition: vtkIndent.h:38
int NumberOfAllocations
Definition: vtkHeap.h:92
virtual size_t GetBlockSize()
Definition: vtkHeap.h:66
size_t Position
Definition: vtkHeap.h:101
replacement for malloc/free and new/delete
Definition: vtkHeap.h:52
size_t BlockSize
Definition: vtkHeap.h:91
static vtkObject * New()
size_t Alignment
Definition: vtkHeap.h:94