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();
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:
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
vtkHeap::Current
vtkHeapBlock * Current
Definition: vtkHeap.h:99
vtkHeap::Reset
void Reset()
vtkHeap::NumberOfBlocks
int NumberOfBlocks
Definition: vtkHeap.h:93
vtkHeap::DeleteAndNext
vtkHeapBlock * DeleteAndNext()
vtkHeap::StringDup
char * StringDup(const char *str)
vtkHeap::Last
vtkHeapBlock * Last
Definition: vtkHeap.h:98
vtkHeap::First
vtkHeapBlock * First
Definition: vtkHeap.h:97
vtkTypeMacro
#define vtkTypeMacro(thisClass, superclass)
Definition: vtkSetGet.h:642
vtkgl::n
GLclampd n
Definition: vtkgl.h:14370
vtkHeap::CleanAll
void CleanAll()
vtkObject
abstract base class for most VTK objects
Definition: vtkObject.h:62
vtkHeap::Alignment
size_t Alignment
Definition: vtkHeap.h:94
vtkHeap::New
static vtkHeap * New()
vtkHeap::GetBlockSize
virtual size_t GetBlockSize()
Definition: vtkHeap.h:66
VTKCOMMONMISC_EXPORT
#define VTKCOMMONMISC_EXPORT
Definition: vtkCommonMiscModule.h:15
vtkHeap::PrintSelf
void PrintSelf(ostream &os, vtkIndent indent)
vtkHeap::Add
void Add(size_t blockSize)
vtkHeap::SetBlockSize
virtual void SetBlockSize(size_t)
vtkHeap::vtkHeap
vtkHeap()
vtkIndent
a simple class to control print indentation
Definition: vtkIndent.h:39
vtkHeap::BlockSize
size_t BlockSize
Definition: vtkHeap.h:91
vtkHeap::~vtkHeap
~vtkHeap()
vtkHeap::AllocateMemory
void * AllocateMemory(size_t n)
vtkGetMacro
#define vtkGetMacro(name, type)
Definition: vtkSetGet.h:93
vtkHeap
replacement for malloc/free and new/delete
Definition: vtkHeap.h:53
vtkObject.h
vtkHeap::Position
size_t Position
Definition: vtkHeap.h:101
vtkHeap::NumberOfAllocations
int NumberOfAllocations
Definition: vtkHeap.h:92
vtkCommonMiscModule.h