Emergency 2017 Dokumentation  v3.0.1
qsf::PagedAllocator< T, PAGESIZE > Class Template Reference

Paged allocator class template. More...

#include <PagedAllocator.h>

Public Member Functions

 PagedAllocator (size_t pageSize=PAGESIZE)
 Constructor. More...
 
 ~PagedAllocator ()
 Destructor. More...
 
void clear ()
 Clear all allocated memory, effectively destroying all instances. More...
 
bool empty () const
 Check if there are any element currently registered. More...
 
T * alloc ()
 Allocate a new element without calling its constructor. More...
 
void free (T *element)
 Free an element without calling its destructor. More...
 
T * create ()
 Create a new element by its default constructor. More...
 
template<typename A >
T * create (A a)
 Create a new element using a constructor with one argument. More...
 
template<typename A , typename B >
T * create (A a, B b)
 Create a new element using a constructor with 2 arguments. More...
 
template<typename A , typename B , typename C >
T * create (A a, B b, C c)
 Create a new element using a constructor with 3 arguments. More...
 
template<typename A , typename B , typename C , typename D >
T * create (A a, B b, C c, D d)
 Create a new element using a constructor with 4 arguments. More...
 
template<typename A , typename B , typename C , typename D , typename E >
T * create (A a, B b, C c, D d, E e)
 Create a new element using a constructor with 5 arguments. More...
 
void destroy (T *element)
 Free an element, its destructor is called. More...
 
bool isManaged (const T *element) const
 Check whether the given element is managed by this allocator, no matter if it is currently in use or not. More...
 
bool isUsed (const T *element) const
 Check whether the given element is currently used and managed by this allocator. More...
 
bool isUnused (const T *element) const
 Check whether the given element is currently not used and managed by this allocator. More...
 

Detailed Description

template<typename T, int PAGESIZE = 16>
class qsf::PagedAllocator< T, PAGESIZE >

Paged allocator class template.

Note
  • The create method currently supports up to 3 parameters; feel free to extend this if more parameters are needed
Todo:
  • TODO(fw): Page size could be made changeable at any time (with effect for new pages only, of course) by saving the size of each page.
  • TODO(fw): We could possibly use a bitfield or similar to store for each element whether it is used - that would improve performance for isUsed() and isUnused() checks.

Definition at line 38 of file PagedAllocator.h.

Constructor & Destructor Documentation

template<typename T , int PAGESIZE>
qsf::PagedAllocator< T, PAGESIZE >::PagedAllocator ( size_t  pageSize = PAGESIZE)
inlineexplicit

Constructor.

Definition at line 21 of file PagedAllocator-inl.h.

template<typename T , int PAGESIZE>
qsf::PagedAllocator< T, PAGESIZE >::~PagedAllocator ( )
inline

Destructor.

Definition at line 28 of file PagedAllocator-inl.h.

Member Function Documentation

template<typename T , int PAGESIZE>
T * qsf::PagedAllocator< T, PAGESIZE >::alloc ( )

Allocate a new element without calling its constructor.

Definition at line 59 of file PagedAllocator-inl.h.

template<typename T , int PAGESIZE>
void qsf::PagedAllocator< T, PAGESIZE >::clear ( )

Clear all allocated memory, effectively destroying all instances.

Definition at line 35 of file PagedAllocator-inl.h.

template<typename T , int PAGESIZE>
T * qsf::PagedAllocator< T, PAGESIZE >::create ( )

Create a new element by its default constructor.

Definition at line 104 of file PagedAllocator-inl.h.

template<typename T , int PAGESIZE>
template<typename A >
T * qsf::PagedAllocator< T, PAGESIZE >::create ( a)

Create a new element using a constructor with one argument.

Definition at line 117 of file PagedAllocator-inl.h.

template<typename T , int PAGESIZE>
template<typename A , typename B >
T * qsf::PagedAllocator< T, PAGESIZE >::create ( a,
b 
)

Create a new element using a constructor with 2 arguments.

Definition at line 130 of file PagedAllocator-inl.h.

template<typename T , int PAGESIZE>
template<typename A , typename B , typename C >
T * qsf::PagedAllocator< T, PAGESIZE >::create ( a,
b,
c 
)

Create a new element using a constructor with 3 arguments.

Definition at line 143 of file PagedAllocator-inl.h.

template<typename T , int PAGESIZE>
template<typename A , typename B , typename C , typename D >
T * qsf::PagedAllocator< T, PAGESIZE >::create ( a,
b,
c,
d 
)

Create a new element using a constructor with 4 arguments.

Definition at line 156 of file PagedAllocator-inl.h.

template<typename T , int PAGESIZE>
template<typename A , typename B , typename C , typename D , typename E >
T * qsf::PagedAllocator< T, PAGESIZE >::create ( a,
b,
c,
d,
e 
)

Create a new element using a constructor with 5 arguments.

Definition at line 169 of file PagedAllocator-inl.h.

template<typename T, int PAGESIZE>
void qsf::PagedAllocator< T, PAGESIZE >::destroy ( T *  element)

Free an element, its destructor is called.

Definition at line 182 of file PagedAllocator-inl.h.

template<typename T , int PAGESIZE>
bool qsf::PagedAllocator< T, PAGESIZE >::empty ( ) const

Check if there are any element currently registered.

Definition at line 47 of file PagedAllocator-inl.h.

template<typename T, int PAGESIZE>
void qsf::PagedAllocator< T, PAGESIZE >::free ( T *  element)

Free an element without calling its destructor.

Definition at line 91 of file PagedAllocator-inl.h.

template<typename T, int PAGESIZE>
bool qsf::PagedAllocator< T, PAGESIZE >::isManaged ( const T *  element) const

Check whether the given element is managed by this allocator, no matter if it is currently in use or not.

Definition at line 192 of file PagedAllocator-inl.h.

template<typename T, int PAGESIZE>
bool qsf::PagedAllocator< T, PAGESIZE >::isUnused ( const T *  element) const

Check whether the given element is currently not used and managed by this allocator.

Definition at line 212 of file PagedAllocator-inl.h.

template<typename T, int PAGESIZE>
bool qsf::PagedAllocator< T, PAGESIZE >::isUsed ( const T *  element) const

Check whether the given element is currently used and managed by this allocator.

Definition at line 205 of file PagedAllocator-inl.h.


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