NVIDIA Iray API
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
mi::base::Interface_implement_singleton< I > Class Template Reference

Mixin class template for deriving singleton interface implementations, where the reference count is fixed to one. More...

Inherits I.

Public Member Functions

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...
 
Uuid  get_iid () const
  Returns the interface ID of the most derived interface. More...
 

Detailed Description

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

Mixin class template for deriving singleton interface implementations, where the reference count is fixed to one.

mi::base::Interface_implement is a mixin class template that allows you to derive interface class implementations easily. It provides you with a special 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.

The reference counting is fixed to have a count of always one. It is suitable, for example, for singleton objects that get once allocated and never deallocated.

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

Template Parameters
I The interface class that this class implements.

Member Function Documentation

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

Returns the interface ID of the most derived interface.

template<class I>
virtual const IInterface* mi::base::Interface_implement_singleton< 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_singleton< 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>
virtual Uint32 mi::base::Interface_implement_singleton< I >::release ( ) const
inlinevirtual

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.

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

Returns the fixed reference count of one.

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