Math API nvidia_logo_transpbg.gif Up
mi::base::Default_allocator Class Reference

A default allocator implementation based on global new and delete. More...

#include <default_allocator.h>

Inheritance diagram for mi::base::Default_allocator:

Public Types

using Self = Interface_declare< id1, ... >
 Own type. More...
 
using IID = Uuid_t< id1, ... >
 Declares the interface ID (IID) of this interface. More...
 

Public Member Functions

void * malloc (Size size) override
 Allocates a memory block of the given size. More...
 
void free (void *memory) override
 Releases the given memory block. More...
 
Uint32 retain () const override
 Returns the fixed reference count of one. More...
 
Uint32 release () const override
 Returns the fixed reference count of one. More...
 
const IInterfaceget_interface (const Uuid &interface_id) const override
 Acquires a const interface. More...
 
IInterfaceget_interface (const Uuid &interface_id) override
 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 override
 Returns the interface ID of the most derived interface. More...
 

Static Public Member Functions

static IAllocatorget_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...
 

Detailed Description

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 File:
#include <mi/base/default_allocator.h>

Member Typedef Documentation

 IID

using mi::base::Interface_declare< id1, ... >::IID = Uuid_t<id1, id2, id3, id4, id5, id6, id7, id8, id9, id10, id11>
inherited

Declares the interface ID (IID) of this interface.

 Self

using mi::base::Interface_declare< id1, ... >::Self = Interface_declare<id1, id2, id3, id4, id5, id6, id7, id8, id9, id10, id11, IInterface >
inherited

Own type.

Member Function Documentation

 compare_iid()

static bool mi::base::Interface_declare< id1, ... >::compare_iid ( const Uuid iid)
inlinestaticinherited

Compares the interface ID iid against the interface ID of this interface and of its ancestors.

Returns
true if iid == IID() or is equal to one of the interface IDs of its ancestors, and false otherwise.

 get_iid()

Uuid mi::base::Interface_implement_singleton< IAllocator >::get_iid ( ) const
inlineoverridevirtualinherited

Returns the interface ID of the most derived interface.

Implements mi::base::IInterface.

 get_interface() [1/2]

const IInterface * mi::base::Interface_implement_singleton< IAllocator >::get_interface ( const Uuid interface_id) const
inlineoverridevirtualinherited

Acquires a const interface.

If this interface is derived from or is the interface with the passed interface_id, then return a non-nullptr 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 nullptr.

In the case of a non-nullptr 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.

 get_interface() [2/2]

IInterface * mi::base::Interface_implement_singleton< IAllocator >::get_interface ( const Uuid interface_id)
inlineoverridevirtualinherited

Acquires a mutable interface.

If this interface is derived from or is the interface with the passed interface_id, then return a non-nullptr 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 nullptr.

In the case of a non-nullptr 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.

 release()

Uint32 mi::base::Interface_implement_singleton< IAllocator >::release ( ) const
inlineoverridevirtualinherited

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.

 retain()

Uint32 mi::base::Interface_implement_singleton< IAllocator >::retain ( ) const
inlineoverridevirtualinherited

Returns the fixed reference count of one.

Implements mi::base::IInterface::retain() with a constant reference count of one.

Implements mi::base::IInterface.