 |
VTK
9.1.0
|
Go to the documentation of this file.
33 template <
class ScalarTypeT>
110 void operator=(
const vtkBuffer&) =
delete;
113 template <
class ScalarT>
119 template <
class ScalarT>
127 template <
typename ScalarT>
130 if (this->Pointer != array)
132 if (this->DeleteFunction)
134 this->DeleteFunction(this->Pointer);
136 this->Pointer = array;
141 template <
typename ScalarT>
144 this->MallocFunction = mallocFunction;
147 template <
typename ScalarT>
150 this->ReallocFunction = reallocFunction;
154 template <
typename ScalarT>
159 this->DeleteFunction =
nullptr;
163 this->DeleteFunction = deleteFunction;
168 template <
typename ScalarT>
172 this->SetBuffer(
nullptr, 0);
176 if (this->MallocFunction)
186 this->SetBuffer(newArray,
size);
187 if (!this->MallocFunction)
189 this->DeleteFunction = free;
199 template <
typename ScalarT>
204 return this->Allocate(0);
207 if (this->Pointer && this->DeleteFunction != free)
210 bool forceFreeFunction =
false;
211 if (this->MallocFunction)
214 if (this->MallocFunction == malloc)
222 forceFreeFunction =
true;
233 std::copy(this->Pointer, this->Pointer + std::min(this->Size, newsize), newArray);
235 this->SetBuffer(newArray, newsize);
236 if (!this->MallocFunction || forceFreeFunction)
238 this->DeleteFunction = free;
246 if (this->ReallocFunction)
249 this->ReallocFunction(this->Pointer, newsize *
sizeof(
ScalarType)));
259 this->Pointer = newArray;
260 this->Size = newsize;
void(* vtkFreeingFunction)(void *)
void SetBuffer(ScalarType *array, vtkIdType size)
Set the memory buffer that this vtkBuffer object will manage.
void SetMallocFunction(vtkMallocingFunction mallocFunction=malloc)
Set the malloc function to be used when allocating space inside this object.
static vtkReallocingFunction GetCurrentReallocFunction()
abstract base class for most VTK objects
static vtkMallocingFunction GetCurrentMallocFunction()
internal storage class used by vtkSOADataArrayTemplate, vtkAOSDataArrayTemplate, and others.
void SetFreeFunction(bool noFreeFunction, vtkFreeingFunction deleteFunction=free)
Set the free function to be used when releasing this object.
void *(* vtkMallocingFunction)(size_t)
void SetReallocFunction(vtkReallocingFunction reallocFunction=realloc)
Set the realloc function to be used when allocating space inside this object.
bool Allocate(vtkIdType size)
Allocate a new buffer that holds size elements.
vtkMallocingFunction MallocFunction
static vtkBuffer< ScalarTypeT > * New()
bool Reallocate(vtkIdType newsize)
Allocate a new buffer that holds newsize elements.
vtkIdType GetSize() const
Return the number of elements the current buffer can hold.
static vtkBuffer< ScalarTypeT > * ExtendedNew()
vtkFreeingFunction DeleteFunction
A class to help modify and restore the global UsingMemkind state, like SetUsingMemkind(newValue),...
void *(* vtkReallocingFunction)(void *, size_t)
static vtkFreeingFunction GetCurrentFreeFunction()
#define VTK_STANDARD_NEW_BODY(thisClass)
vtkReallocingFunction ReallocFunction
ScalarType * GetBuffer()
Access the buffer as a scalar pointer.
vtkTemplateTypeMacro(vtkBuffer< ScalarTypeT >, vtkObject)
const ScalarType * GetBuffer() const