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
int NumberOfBlocks
Definition: vtkHeap.h:92
abstract base class for most VTK objects
Definition: vtkObject.h:60
vtkHeapBlock * Current
Definition: vtkHeap.h:98
vtkHeapBlock * First
Definition: vtkHeap.h:96
virtual void PrintSelf(ostream &os, vtkIndent indent)
vtkHeapBlock * Last
Definition: vtkHeap.h:97
a simple class to control print indentation
Definition: vtkIndent.h:37
int NumberOfAllocations
Definition: vtkHeap.h:91
virtual size_t GetBlockSize()
Definition: vtkHeap.h:65
#define VTK_COMMON_EXPORT
size_t Position
Definition: vtkHeap.h:100
replacement for malloc/free and new/delete
Definition: vtkHeap.h:51
size_t BlockSize
Definition: vtkHeap.h:90
int Alignment
Definition: vtkHeap.h:93
static vtkObject * New()