Developer Documentation
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
AllocatorT< T > Class Template Reference

#include <Package-Staging/Plugin-PoissonReconstruction/PoissonReconstruction/Allocator.h>

Public Member Functions

void reset (void)
 
AllocatorState getState (void) const
 
void rollBack (void)
 
void rollBack (const AllocatorState &state)
 
void set (int blockSize)
 
T * newElements (size_t elements=1)
 

Private Attributes

size_t blockSize
 
size_t index
 
size_t remains
 
std::vector< T * > memory
 

Detailed Description

template<class T>
class AllocatorT< T >

This templated class assists in memory allocation and is well suited for instances when it is known that the sequence of memory allocations is performed in a stack-based manner, so that memory allocated last is released first. It also preallocates memory in chunks so that multiple requests for small chunks of memory do not require separate system calls to the memory manager. The allocator is templated off of the class of objects that we would like it to allocate, ensuring that appropriate constructors and destructors are called as necessary.

Definition at line 46 of file Allocator.h.

Member Function Documentation

template<class T>
AllocatorState AllocatorT< T >::getState ( void  ) const
inline

This method returns the memory state of the allocator.

Definition at line 66 of file Allocator.h.

template<class T>
T* AllocatorT< T >::newElements ( size_t  elements = 1)
inline

This method returns a pointer to an array of elements objects. If there is left over pre-allocated memory, this method simply returns a pointer to the next free piece of memory, otherwise it pre-allocates more memory. Note that if the number of objects requested is larger than the value blockSize with which the allocator was initialized, the request for memory will fail.

Definition at line 138 of file Allocator.h.

template<class T>
void AllocatorT< T >::reset ( void  )
inline

This method is the allocators destructor. It frees up any of the memory that it has allocated.

Definition at line 60 of file Allocator.h.

template<class T>
void AllocatorT< T >::rollBack ( void  )
inline

This method rolls back the allocator so that it makes all of the memory previously allocated available for re-allocation. Note that it does it not call the constructor again, so after this method has been called, assumptions about the state of the values in memory are no longer valid.

Definition at line 78 of file Allocator.h.

template<class T>
void AllocatorT< T >::rollBack ( const AllocatorState state)
inline

This method rolls back the allocator to the previous memory state and makes all of the memory previously allocated available for re-allocation. Note that it does it not call the constructor again, so after this method has been called, assumptions about the state of the values in memory are no longer valid.

Definition at line 94 of file Allocator.h.

template<class T>
void AllocatorT< T >::set ( int  blockSize)
inline

This method initializes the constructor and the blockSize variable specifies the the number of objects that should be pre-allocated at a time.

Definition at line 126 of file Allocator.h.


The documentation for this class was generated from the following file: