iinterface.h File Reference
Description
The basic extensible interface.
Code Example
iinterface.h
/***************************************************************************************************
* Copyright 2024 NVIDIA Corporation. All rights reserved.
**************************************************************************************************/
#ifndef MI_BASE_IINTERFACE_H
#define MI_BASE_IINTERFACE_H
#include <mi/base/types.h>
#include <mi/base/uuid.h>
namespace mi {
namespace base {
// Forward declaration, see below for definition
class IInterface;
class IInterface
{
public:
typedef Uuid_t< 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0>
IID;
static bool compare_iid( const Uuid& iid)
{
return ( iid == IID());
}
virtual Uint32
retain() const = 0;
virtual Uint32
release() const = 0;
virtual const IInterface* get_interface( const Uuid& interface_id ) const = 0;
template <class T>
const T* get_interface() const
{
return static_cast<const T*>( get_interface( typename T::IID()));
}
virtual IInterface* get_interface( const Uuid& interface_id ) = 0;
template <class T>
T* get_interface()
{
return static_cast<T*>( get_interface( typename T::IID()));
}
virtual Uuid
get_iid() const = 0;
protected:
// Acquires a const interface.
//
// Static helper function for implementing #get_interface(const Uuid&). On #IInterface, the
// method terminates the recursive call chain.
//
// \param iinterface The interface to act on.
// \param interface_id Interface ID of the interface to acquire.
static const IInterface* get_interface_static(
const IInterface* iinterface, const Uuid& interface_id)
{
if( interface_id == IID()) {
iinterface->retain();
return iinterface;
}
return 0;
}
// Acquires a mutable interface.
//
// Static helper function for implementing #get_interface(const Uuid&). On #IInterface, the
// method terminates the recursive call chain.
//
// \param iinterface The interface to act on.
// \param interface_id Interface ID of the interface to acquire.
static IInterface* get_interface_static(
IInterface* iinterface, const Uuid& interface_id)
{
if( interface_id == IID()) {
iinterface->retain();
return iinterface;
}
return 0;
}
};
// end group mi_base_iinterface
} // namespace base
} // namespace mi
#endif // MI_BASE_IINTERFACE_H
Namespaces
- namespace
- Common namespace for APIs of NVIDIA Advanced Rendering Center GmbH. More...
- namespace
- Namespace for the Base API. More...
Classes
- class
- The basic extensible interface. More...