neuray API Programmer's Manual

mi::base::Interface_merger< typename MAJOR, typename MINOR> Template Class Reference

[Interface Framework Technology]

template< typename MAJOR, typename MINOR>

class mi::base::Interface_merger< typename MAJOR, typename MINOR>

Description

This mixin merges the implementation of one interface with a second interface. Multiple inheritance from interfaces is not possible due to ambiguities. This mixin resolves the ambiguities by re-implementing the methods of mi::base::IInterface.

Note that this mixin class derives from an implementation and an interface, in contrast to mi::base::Interface_implement_2, which derives from two interfaces. Basically, Interface_merger<Interface_implement<I1>,I2> is equivalent to Interface_implement<I1,I2>. The benefit of this mixin class is that you are not bound to use Interface_implement, any valid implementation of an interface will do.

The template parameters representing the base classes are called MAJOR and MINOR. Note that the derivation is not symmetric:

  • MAJOR has to be an implementation of an interface, MINOR has to be just an interface

  • retain() and release() are redirected to the MAJOR base class

  • compared_iid() and get_interface() are redirected to the MAJOR base class first, the MINOR base class is only queried on failure. For example, get_interface< mi::base::IInterface>() will always return the MAJOR base class.

  • get_iid() is redirected to the MAJOR base class.

Note that some versions of Microsoft Visual C++ are known to produce the bogus warning

‎ disable C4505: <class::method>: unreferenced local function has been removed 
in conjunction with this class. This warning can be disabled with
‎ #include <mi/base/config.h>
 #ifdef MI_COMPILER_MSC
 #pragma warning( disable : 4505 )
 #endif
Note that the pragma affects the entire translation unit. Therefore, the warning is not disabled by default.

Public Typedefs

typedef MAJOR  MAJOR_BASE
Typedef for the MAJOR base class.
typedef MINOR  MINOR_BASE
Typedef for the MINOR base class.

Public Member Functions

const MAJOR* cast_to_major() const
Returns a pointer to the MAJOR base class. More...
MAJOR* cast_to_major()
Returns a pointer to the MAJOR base class. More...
Uuid get_iid() const
Reimplements mi::base::IInterface::get_iid(). More...
const IInterfaceget_interface( const Uuid& interface_id) const
Reimplements mi::base::IInterface::get_interface(const Uuid&) const. More...
template< class T>const T* get_interface() const
Reimplements mi::base::IInterface::get_interface() const. More...
IInterfaceget_interface( const Uuid& interface_id)
Reimplements mi::base::IInterface::get_interface(const Uuid&). More...
template< class T>T* get_interface()
Reimplements mi::base::IInterface::get_interface(). More...
mi::​Uint32 release() const
Reimplements mi::base::IInterface::release(). More...
mi::​Uint32 retain() const
Reimplements mi::base::IInterface::retain(). More...

Static Public Member Functions

static bool  compare_iid( const Uuid& iid)
Reimplements mi::base::IInterface::compare_iid(). More...

Typedefs

typedef MAJOR mi::base::Interface_merger< typename MAJOR, typename MINOR>::MAJOR_BASE

Typedef for the MAJOR base class.

typedef MINOR mi::base::Interface_merger< typename MAJOR, typename MINOR>::MINOR_BASE

Typedef for the MINOR base class.

Member Functions

const MAJOR* mi::base::Interface_merger< typename MAJOR, typename MINOR>::cast_to_major() const [inline]

Returns a pointer to the MAJOR base class. Note that mi::base::IInterface is an ambiguous base class. Often you just need a pointer to mi::base::IInterface but do not really care to which base class it actually points to. This method is intended to be used in these cases. It returns the pointer to the MAJOR base class, which can then be statically casted to mi::base::IInterface (unless Interface_merger is nested).

Note:

The name cast_to_major() of this method emphasizes that it behaves similar to a static cast, in particular, it does not increase the reference count.

MAJOR* mi::base::Interface_merger< typename MAJOR, typename MINOR>::cast_to_major() [inline]

Returns a pointer to the MAJOR base class. Note that mi::base::IInterface is an ambiguous base class. Often you just need a pointer to mi::base::IInterface but do not really care to which base class it actually points to. This method is intended to be used in these cases. It returns the pointer to the MAJOR base class, which can then be statically casted to mi::base::IInterface (unless Interface_merger is nested).

Note:

The name cast_to_major() of this method emphasizes that it behaves similar to a static cast, in particular, it does not increase the reference count.

static bool mi::base::Interface_merger< typename MAJOR, typename MINOR>::compare_iid( const Uuid& iid) [inline, static]

Reimplements mi::base::IInterface::compare_iid(). Forwards the call to the MAJOR base class, and then, in case of failure, to the MINOR base class.

Uuid mi::base::Interface_merger< typename MAJOR, typename MINOR>::get_iid() const [inline]

Reimplements mi::base::IInterface::get_iid(). Forwards the call to the MAJOR base class.

const IInterface* mi::base::Interface_merger< typename MAJOR, typename MINOR>::get_interface( const Uuid& interface_id) const [inline]

Reimplements mi::base::IInterface::get_interface(const Uuid&) const. Forwards the call to the MAJOR base class, and then, in case of failure, to the MINOR base class.

template< class T>

const T* mi::base::Interface_merger< typename MAJOR, typename MINOR>::get_interface() const [inline]

Reimplements mi::base::IInterface::get_interface() const. The implementation is identical, but needed for visibility reasons.

IInterface* mi::base::Interface_merger< typename MAJOR, typename MINOR>::get_interface( const Uuid& interface_id) [inline]

Reimplements mi::base::IInterface::get_interface(const Uuid&). Forwards the call to the MAJOR base class, and then, in case of failure, to the MINOR base class.

template< class T>

T* mi::base::Interface_merger< typename MAJOR, typename MINOR>::get_interface() [inline]

Reimplements mi::base::IInterface::get_interface(). The implementation is identical, but needed for visibility reasons.

mi::​Uint32 mi::base::Interface_merger< typename MAJOR, typename MINOR>::release() const [inline]

Reimplements mi::base::IInterface::release(). Forwards the call to the MAJOR base class.

mi::​Uint32 mi::base::Interface_merger< typename MAJOR, typename MINOR>::retain() const [inline]

Reimplements mi::base::IInterface::retain(). Forwards the call to the MAJOR base class.