A default allocator implementation based on global new and delete. More...
Public Types | |
typedef Interface_declare< id1, id2, id3, id4, id5, id6, id7, id8, id9, id10, id11, IInterface > |
Self |
Own type. More... |
|
typedef Uuid_t< id1, id2, id3, id4, id5, id6, id7, id8, id9, id10, id11 > |
IID |
Declares the interface ID (IID) of this interface. More... |
|
Public Member Functions | |
virtual void * | malloc (Size size) |
Allocates a memory block of the given size. More... |
|
virtual void | free (void *memory) |
Releases the given memory block. More... |
|
virtual Uint32 | retain () const |
Returns the fixed reference count of one. More... |
|
virtual Uint32 | release () const |
Returns the fixed reference count of one. More... |
|
virtual const IInterface * | get_interface (const Uuid &interface_id) const |
Acquires a const interface. More... |
|
virtual IInterface * | get_interface (const Uuid &interface_id) |
Acquires a mutable interface. More... |
|
template<class T > | |
const T * | get_interface () const |
Acquires a const interface from another. More... |
|
template<class T > | |
T * | get_interface () |
Acquires a mutable interface from another. More... |
|
Uuid | get_iid () const |
Returns the interface ID of the most derived interface. More... |
|
Static Public Member Functions | |
static IAllocator * | get_instance () |
Returns the single instance of the default allocator. More... |
|
static bool | compare_iid (const Uuid &iid) |
Compares the interface ID iid against the interface ID of this interface and of its ancestors. More... |
|
A default allocator implementation based on global new and delete.
This implementation realizes the singleton pattern. An instance of the default allocator can be obtained through the static inline method mi::base::Default_allocator::get_instance().
#include <mi/base/default_allocator.h>
|
inherited |
Declares the interface ID (IID) of this interface.
|
inherited |
Own type.
|
inlinestaticinherited |
Compares the interface ID iid
against the interface ID of this interface and of its ancestors.
true
if iid
== IID()
or is equal to one of the interface IDs of its ancestors, and false
otherwise.
|
inlinevirtual |
Releases the given memory block.
Implements mi::base::IAllocator::free through a global operator
delete
call.
memory | A memory block previously allocated by a call to malloc(). If memory is NULL , no operation is performed. |
Implements mi::base::IAllocator.
|
inlinevirtualinherited |
Returns the interface ID of the most derived interface.
Implements mi::base::IInterface.
|
inlinestatic |
Returns the single instance of the default allocator.
|
inlineinherited |
Acquires a const interface from another.
If this interface supports the interface T
, then the method returns a non-NULL
const
pointer to the interface T
. Otherwise, the method returns NULL
.
In the case of a non-NULL
return value, the caller receives ownership of the new interface pointer, whose reference count has been retained once. The caller must release the returned interface pointer at the end to prevent a memory leak.
This templated member function is a wrapper of the non-template variant for the user's convenience. It eliminates the need to apply static_cast
to the returned pointer, since the return type already is a const pointer to the type T
specified as template parameter.
T | The requested interface type. |
|
inlineinherited |
Acquires a mutable interface from another.
If this interface supports the interface T
, then the method returns a non-NULL
pointer to the interface T
. Otherwise, the method returns NULL
.
In the case of a non-NULL
return value, the caller receives ownership of the new interface pointer, whose reference count has been retained once. The caller must release the returned interface pointer at the end to prevent a memory leak.
This templated member function is a wrapper of the non-template variant for the user's convenience. It eliminates the need to apply static_cast
to the returned pointer, since the return type already is a pointer to the type T
specified as template parameter.
T | The requested interface type. |
|
inlinevirtualinherited |
Acquires a const interface.
If this interface is derived from or is the interface with the passed interface_id
, then return a non-NULL
const
mi::base::IInterface* that can be casted via static_cast
to an interface pointer of the interface type corresponding to the passed interface_id
. Otherwise return NULL
.
In the case of a non-NULL
return value, the caller receives ownership of the new interface pointer, whose reference count has been retained once. The caller must release the returned interface pointer at the end to prevent a memory leak.
Implements mi::base::IInterface.
|
inlinevirtualinherited |
Acquires a mutable interface.
If this interface is derived from or is the interface with the passed interface_id
, then return a non-NULL
mi::base::IInterface* that can be casted via static_cast
to an interface pointer of the interface type corresponding to the passed interface_id
. Otherwise return NULL
.
In the case of a non-NULL
return value, the caller receives ownership of the new interface pointer, whose reference count has been retained once. The caller must release the returned interface pointer at the end to prevent a memory leak.
Implements mi::base::IInterface.
|
inlinevirtual |
Allocates a memory block of the given size.
Implements mi::base::IAllocator::malloc through a global non-throwing operator
new
call.
size | The requested size of memory in bytes. It may be zero. |
Implements mi::base::IAllocator.
|
inlinevirtualinherited |
Returns the fixed reference count of one.
Implements mi::base::IInterface::release() with a constant reference count of one. The object will never be deleted through a release call.
Implements mi::base::IInterface.
|
inlinevirtualinherited |
Returns the fixed reference count of one.
Implements mi::base::IInterface::retain() with a constant reference count of one.
Implements mi::base::IInterface.