NVIDIA Iray: Math API nvidia_logo_transpbg.gif Up
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
mi::base::Interface_implement< I > Class Template Reference

Mixin class template for deriving interface implementations. More...

Inherits I.

Public Member Functions

 Interface_implement (Uint32 initial=1)
 Constructor. More...
 
 Interface_implement (const Interface_implement< I > &other)
 Copy constructor. More...
 
Interface_implement< I > & operator= (const Interface_implement< I > &other)
 Assignment operator. More...
 
virtual Uint32 retain () const
 Increments the reference count. More...
 
virtual Uint32 release () const
 Decrements the reference count. More...
 
virtual const IInterfaceget_interface (const Uuid &interface_id) const
 Acquires a const interface. More...
 
virtual IInterfaceget_interface (const Uuid &interface_id)
 Acquires a mutable interface. More...
 
Uuid get_iid () const
 Returns the interface ID of the most derived interface. More...
 

Protected Member Functions

Atom32refcount () const
 Get the current refcount. More...
 

Detailed Description

template<class I>
class mi::base::Interface_implement< I >

Mixin class template for deriving interface implementations.

mi::base::Interface_implement is a mixin class template that allows you to derive interface class implementations easily. It provides you with the full implementation of reference counting and the mi::base::IInterface::get_interface(const Uuid&) method. It requires that you used interfaces derived from the corresponding mixin class template mi::base::Interface_declare.

mi::base::Interface_implement is derived from the interface I.

Template Parameters
IThe interface class that this class implements.
Include File:
#include <mi/base/interface_implement.h>

Constructor & Destructor Documentation

template<class I>
mi::base::Interface_implement< I >::Interface_implement ( Uint32  initial = 1)
inline

Constructor.

Parameters
initialThe initial reference count (defaults to 1).
template<class I>
mi::base::Interface_implement< I >::Interface_implement ( const Interface_implement< I > &  other)
inline

Copy constructor.

Initializes the reference count to 1.

Member Function Documentation

template<class I>
Uuid mi::base::Interface_implement< I >::get_iid ( ) const
inline

Returns the interface ID of the most derived interface.

template<class I>
virtual const IInterface* mi::base::Interface_implement< I >::get_interface ( const Uuid interface_id) const
inlinevirtual

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.

template<class I>
virtual IInterface* mi::base::Interface_implement< I >::get_interface ( const Uuid interface_id)
inlinevirtual

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.

template<class I>
Interface_implement<I>& mi::base::Interface_implement< I >::operator= ( const Interface_implement< I > &  other)
inline

Assignment operator.

The reference count of *this and other remain unchanged.

template<class I>
Atom32& mi::base::Interface_implement< I >::refcount ( ) const
inlineprotected

Get the current refcount.

template<class I>
virtual Uint32 mi::base::Interface_implement< I >::release ( ) const
inlinevirtual

Decrements the reference count.

Decrements the reference count of the object referenced through this interface and returns the new reference count. If the reference count dropped to zero, the object will be deleted. The operation is thread-safe.

template<class I>
virtual Uint32 mi::base::Interface_implement< I >::retain ( ) const
inlinevirtual

Increments the reference count.

Increments the reference count of the object referenced through this interface and returns the new reference count. The operation is thread-safe.