Jpp  17.3.1
the software that should make you happy
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Static Public Member Functions | Static Public Attributes | Protected Member Functions | List of all members
JLANG::JObjectAllocator< T, JAllocator_t > Class Template Reference

Base class for customized new/delete operators. More...

#include <JObjectAllocator.hh>

Static Public Member Functions

static JAllocator_t & getInstance ()
 Get reference to unique instance of this class object. More...
 
static void * operator new (const std::size_t size)
 new operator. More...
 
static void operator delete (void *p, const std::size_t size)
 delete operator. More...
 

Static Public Attributes

static const std::size_t BLOCK_SIZE = sizeof(T)
 size of object [Byte] More...
 

Protected Member Functions

 JObjectAllocator ()
 Defaul constructor. More...
 

Detailed Description

template<class T, class JAllocator_t>
class JLANG::JObjectAllocator< T, JAllocator_t >

Base class for customized new/delete operators.

The first template argument refers to the data type for new/delete operations and the second to the memory management class.

Possible syntax:

#include "JLang/JRAM.hh"
     class A : public JLANG::JObjectAllocator<A, JRAM> {
     };

In this case, the new/delete operations are implemented by the JLANG::JRAM class.

Definition at line 29 of file JObjectAllocator.hh.

Constructor & Destructor Documentation

template<class T, class JAllocator_t>
JLANG::JObjectAllocator< T, JAllocator_t >::JObjectAllocator ( )
inlineprotected

Defaul constructor.

Definition at line 35 of file JObjectAllocator.hh.

36  {}

Member Function Documentation

template<class T, class JAllocator_t>
static JAllocator_t& JLANG::JObjectAllocator< T, JAllocator_t >::getInstance ( )
inlinestatic

Get reference to unique instance of this class object.

Returns
reference to this class object

Definition at line 44 of file JObjectAllocator.hh.

45  {
46  static JAllocator_t allocator(BLOCK_SIZE);
47 
48  return allocator;
49  }
static const std::size_t BLOCK_SIZE
size of object [Byte]
template<class T, class JAllocator_t>
static void* JLANG::JObjectAllocator< T, JAllocator_t >::operator new ( const std::size_t  size)
inlinestatic

new operator.

Returns
pointer to new object (or NULL)

Definition at line 60 of file JObjectAllocator.hh.

61  {
62  return getInstance().allocate();
63  }
static JAllocator_t & getInstance()
Get reference to unique instance of this class object.
template<class T, class JAllocator_t>
static void JLANG::JObjectAllocator< T, JAllocator_t >::operator delete ( void *  p,
const std::size_t  size 
)
inlinestatic

delete operator.

Parameters
ppointer to object to be freed
sizenumber of bytes

Definition at line 72 of file JObjectAllocator.hh.

73  {
74  getInstance().free(p);
75  }
static JAllocator_t & getInstance()
Get reference to unique instance of this class object.

Member Data Documentation

template<class T, class JAllocator_t>
const std::size_t JLANG::JObjectAllocator< T, JAllocator_t >::BLOCK_SIZE = sizeof(T)
static

size of object [Byte]

Definition at line 52 of file JObjectAllocator.hh.


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