Gainput  v1.0.0
Public Types | Public Member Functions | List of all members
gainput::Allocator Class Referenceabstract

Interface used to pass custom allocators to the library. More...

#include <GainputAllocator.h>

Inheritance diagram for gainput::Allocator:
gainput::DefaultAllocator gainput::TrackingAllocator

Public Types

enum  { DefaultAlign = 0 }
 

Public Member Functions

virtual void * Allocate (size_t size, size_t align=DefaultAlign)=0
 Allocates a number of bytes and returns a pointer to the allocated memory. More...
 
virtual void Deallocate (void *ptr)=0
 Deallocates the given memory. More...
 
template<class T >
T * New ()
 An operator new-like function that allocates memory and calls T's constructor. More...
 
template<class T , class P0 >
T * New (P0 &p0)
 An operator new-like function that allocates memory and calls T's constructor with one parameter. More...
 
template<class T , class P0 >
T * New (const P0 &p0)
 An operator new-like function that allocates memory and calls T's constructor with one parameter. More...
 
template<class T , class P0 , class P1 >
T * New (P0 &p0, P1 &p1)
 An operator new-like function that allocates memory and calls T's constructor with two parameters. More...
 
template<class T , class P0 , class P1 >
T * New (const P0 &p0, P1 &p1)
 An operator new-like function that allocates memory and calls T's constructor with two parameters. More...
 
template<class T , class P0 , class P1 >
T * New (P0 &p0, const P1 &p1)
 An operator new-like function that allocates memory and calls T's constructor with two parameters. More...
 
template<class T , class P0 , class P1 , class P2 >
T * New (P0 &p0, const P1 &p1, const P2 &p2)
 An operator new-like function that allocates memory and calls T's constructor with the given parameters. More...
 
template<class T , class P0 , class P1 , class P2 >
T * New (P0 &p0, const P1 &p1, P2 &p2)
 An operator new-like function that allocates memory and calls T's constructor with the given parameters. More...
 
template<class T , class P0 , class P1 , class P2 , class P3 >
T * New (P0 &p0, P1 &p1, P2 &p2, P3 &p3)
 An operator new-like function that allocates memory and calls T's constructor with the given parameters. More...
 
template<class T , class P0 , class P1 , class P2 , class P3 >
T * New (P0 &p0, const P1 &p1, P2 &p2, P3 &p3)
 An operator new-like function that allocates memory and calls T's constructor with the given parameters. More...
 
template<class T , class P0 , class P1 , class P2 , class P3 , class P4 >
T * New (P0 &p0, P1 &p1, P2 &p2, P3 &p3, P4 &p4)
 An operator new-like function that allocates memory and calls T's constructor with the given parameters. More...
 
template<class T , class P0 , class P1 , class P2 , class P3 , class P4 >
T * New (P0 &p0, const P1 &p1, P2 &p2, P3 &p3, P4 &p4)
 An operator new-like function that allocates memory and calls T's constructor with the given parameters. More...
 
template<class T >
void Delete (T *ptr)
 An operator delete-like function that calls ptr's constructor and deallocates the memory. More...
 

Detailed Description

Interface used to pass custom allocators to the library.

If you want the library to use your custom allocator you should implement this interface. Specifically, you should provide implementations for the Allocate() and Deallocate() functions. All other (template) member functions are simply based on those two functions.

See also
DefaultAllocator

Member Function Documentation

◆ Allocate()

virtual void* gainput::Allocator::Allocate ( size_t  size,
size_t  align = DefaultAlign 
)
pure virtual

Allocates a number of bytes and returns a pointer to the allocated memory.

Parameters
sizeThe number of bytes to allocate.
Returns
A memory block encompassing at least size bytes.

Implemented in gainput::TrackingAllocator, and gainput::DefaultAllocator.

◆ Deallocate()

virtual void gainput::Allocator::Deallocate ( void *  ptr)
pure virtual

Deallocates the given memory.

Parameters
ptrThe memory block to deallocate.

Implemented in gainput::TrackingAllocator, and gainput::DefaultAllocator.

◆ Delete()

template<class T >
void gainput::Allocator::Delete ( T *  ptr)
inline

An operator delete-like function that calls ptr's constructor and deallocates the memory.

Parameters
ptrThe object to destruct and deallocate.

◆ New() [1/12]

template<class T >
T* gainput::Allocator::New ( )
inline

An operator new-like function that allocates memory and calls T's constructor.

Returns
A pointer to an initialized instance of T.
Examples:
/samples/gesture/gesturesample.cpp.

◆ New() [2/12]

template<class T , class P0 >
T* gainput::Allocator::New ( P0 &  p0)
inline

An operator new-like function that allocates memory and calls T's constructor with one parameter.

Returns
A pointer to an initialized instance of T.

◆ New() [3/12]

template<class T , class P0 >
T* gainput::Allocator::New ( const P0 &  p0)
inline

An operator new-like function that allocates memory and calls T's constructor with one parameter.

Returns
A pointer to an initialized instance of T.

◆ New() [4/12]

template<class T , class P0 , class P1 >
T* gainput::Allocator::New ( P0 &  p0,
P1 &  p1 
)
inline

An operator new-like function that allocates memory and calls T's constructor with two parameters.

Returns
A pointer to an initialized instance of T.

◆ New() [5/12]

template<class T , class P0 , class P1 >
T* gainput::Allocator::New ( const P0 &  p0,
P1 &  p1 
)
inline

An operator new-like function that allocates memory and calls T's constructor with two parameters.

Returns
A pointer to an initialized instance of T.

◆ New() [6/12]

template<class T , class P0 , class P1 >
T* gainput::Allocator::New ( P0 &  p0,
const P1 &  p1 
)
inline

An operator new-like function that allocates memory and calls T's constructor with two parameters.

Returns
A pointer to an initialized instance of T.

◆ New() [7/12]

template<class T , class P0 , class P1 , class P2 >
T* gainput::Allocator::New ( P0 &  p0,
const P1 &  p1,
const P2 &  p2 
)
inline

An operator new-like function that allocates memory and calls T's constructor with the given parameters.

Returns
A pointer to an initialized instance of T.

◆ New() [8/12]

template<class T , class P0 , class P1 , class P2 >
T* gainput::Allocator::New ( P0 &  p0,
const P1 &  p1,
P2 &  p2 
)
inline

An operator new-like function that allocates memory and calls T's constructor with the given parameters.

Returns
A pointer to an initialized instance of T.

◆ New() [9/12]

template<class T , class P0 , class P1 , class P2 , class P3 >
T* gainput::Allocator::New ( P0 &  p0,
P1 &  p1,
P2 &  p2,
P3 &  p3 
)
inline

An operator new-like function that allocates memory and calls T's constructor with the given parameters.

Returns
A pointer to an initialized instance of T.

◆ New() [10/12]

template<class T , class P0 , class P1 , class P2 , class P3 >
T* gainput::Allocator::New ( P0 &  p0,
const P1 &  p1,
P2 &  p2,
P3 &  p3 
)
inline

An operator new-like function that allocates memory and calls T's constructor with the given parameters.

Returns
A pointer to an initialized instance of T.

◆ New() [11/12]

template<class T , class P0 , class P1 , class P2 , class P3 , class P4 >
T* gainput::Allocator::New ( P0 &  p0,
P1 &  p1,
P2 &  p2,
P3 &  p3,
P4 &  p4 
)
inline

An operator new-like function that allocates memory and calls T's constructor with the given parameters.

Returns
A pointer to an initialized instance of T.

◆ New() [12/12]

template<class T , class P0 , class P1 , class P2 , class P3 , class P4 >
T* gainput::Allocator::New ( P0 &  p0,
const P1 &  p1,
P2 &  p2,
P3 &  p3,
P4 &  p4 
)
inline

An operator new-like function that allocates memory and calls T's constructor with the given parameters.

Returns
A pointer to an initialized instance of T.

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