Math API nvidia_logo_transpbg.gif Up
interface_declare.h
Go to the documentation of this file.
1/***************************************************************************************************
2 * Copyright 2023 NVIDIA Corporation. All rights reserved.
3 **************************************************************************************************/
6
7#ifndef MI_BASE_INTERFACE_DECLARE_H
8#define MI_BASE_INTERFACE_DECLARE_H
9
10#include <mi/base/iinterface.h>
11#include <mi/base/types.h>
12#include <mi/base/uuid.h>
13
14namespace mi {
15namespace base {
16
21// Forward declaration
22class IInterface;
23
38template <Uint32 id1, Uint16 id2, Uint16 id3
39 , Uint8 id4, Uint8 id5, Uint8 id6, Uint8 id7
40 , Uint8 id8, Uint8 id9, Uint8 id10, Uint8 id11
41 , class I = IInterface>
42class Interface_declare : public I
43{
44public:
47
50
56 static bool compare_iid( const Uuid& iid) {
57 if( iid == IID())
58 return true;
59 return I::compare_iid( iid);
60 }
61
62protected:
63 // Acquires a const interface.
64 //
65 // Static helper function for implementing #get_interface(const Uuid&).
66 //
67 // \param iinterface The interface to act on.
68 // \param interface_id Interface ID of the interface to acquire.
69 static const IInterface* get_interface_static(
70 const IInterface* iinterface,
71 const Uuid& interface_id)
72 {
73 if( interface_id == IID()) {
74 const Self* self = static_cast<const Self *>( iinterface);
75 self->retain();
76 return self;
77 }
78 return I::get_interface_static( iinterface, interface_id);
79 }
80
81 // Acquires a mutable interface.
82 //
83 // Static helper function for implementing #get_interface(const Uuid&).
84 //
85 // \param iinterface The interface to act on.
86 // \param interface_id Interface ID of the interface to acquire.
87 static IInterface* get_interface_static(
88 IInterface* iinterface,
89 const Uuid& interface_id)
90 {
91 if( interface_id == IID()) {
92 Self* self = static_cast<Self*>( iinterface);
93 self->retain();
94 return self;
95 }
96 return I::get_interface_static( iinterface, interface_id);
97 }
98};
99 // end group mi_base_iinterface
101
102} // namespace base
103} // namespace mi
104
105#endif // MI_BASE_INTERFACE_DECLARE_H
The basic extensible interface.
Definition: iinterface.h:103
Mixin class template for deriving new interface declarations.
Definition: interface_declare.h:43
Class template for a compile-time representation of universally unique identifiers (UUIDs or GUIDs).
Definition: uuid.h:122
Uuid_t< id1, ... > IID
Declares the interface ID (IID) of this interface.
Definition: interface_declare.h:49
Interface_declare< id1, ... > Self
Own type.
Definition: interface_declare.h:46
static bool compare_iid(const Uuid &iid)
Compares the interface ID iid against the interface ID of this interface and of its ancestors.
Definition: interface_declare.h:56
unsigned int Uint32
32-bit unsigned integer.
Definition: types.h:49
unsigned char Uint8
8-bit unsigned integer.
Definition: types.h:47
unsigned short Uint16
16-bit unsigned integer.
Definition: types.h:48
The basic extensible interface.
Common namespace for APIs of NVIDIA Advanced Rendering Center GmbH.
Definition: math.h:22
A 128 bit representation of a universally unique identifier (UUID or GUID).
Definition: uuid.h:26
Basic types.
A 128 bit representation of a universally unique identifier (UUID or GUID).