MDL SDK API
Up
Main Page
Related Pages
Modules
Namespaces
Classes
Files
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Groups
Pages
iinterface.h
Go to the documentation of this file.
1
/***************************************************************************************************
2
* Copyright 2022 NVIDIA Corporation. All rights reserved.
3
**************************************************************************************************/
6
7
#ifndef MI_BASE_IINTERFACE_H
8
#define MI_BASE_IINTERFACE_H
9
10
#include <
mi/base/types.h
>
11
#include <
mi/base/uuid.h
>
12
13
namespace
mi {
14
15
namespace
base {
16
36
// Forward declaration, see below for definition
37
class
IInterface;
38
102
class
IInterface
103
{
104
public
:
105
112
typedef
Uuid_t<0,0,0,0,0,0,0,0,0,0,0>
IID
;
113
117
static
bool
compare_iid
(
const
Uuid
& iid)
118
{
119
return
( iid ==
IID
());
120
}
121
128
virtual
Uint32
retain
()
const
= 0;
129
137
virtual
Uint32
release
()
const
= 0;
138
151
virtual
const
IInterface
*
get_interface
(
const
Uuid
& interface_id )
const
= 0;
152
168
template
<
class
T>
169
const
T*
get_interface
()
const
170
{
171
return
static_cast<
const
T*
>
(
get_interface
(
typename
T::IID()));
172
}
173
186
virtual
IInterface
*
get_interface
(
const
Uuid
& interface_id ) = 0;
187
203
template
<
class
T>
204
T*
get_interface
()
205
{
206
return
static_cast<
T*
>
(
get_interface
(
typename
T::IID()));
207
}
208
210
virtual
Uuid
get_iid
()
const
= 0;
211
212
protected
:
213
// Acquires a const interface.
214
//
215
// Static helper function for implementing #get_interface(const Uuid&). On #IInterface, the
216
// method terminates the recursive call chain.
217
//
218
// \param iinterface The interface to act on.
219
// \param interface_id Interface ID of the interface to acquire.
220
static
const
IInterface
* get_interface_static(
221
const
IInterface
* iinterface,
const
Uuid
& interface_id)
222
{
223
if
( interface_id ==
IID
()) {
224
iinterface->
retain
();
225
return
iinterface;
226
}
227
return
0;
228
}
229
230
// Acquires a mutable interface.
231
//
232
// Static helper function for implementing #get_interface(const Uuid&). On #IInterface, the
233
// method terminates the recursive call chain.
234
//
235
// \param iinterface The interface to act on.
236
// \param interface_id Interface ID of the interface to acquire.
237
static
IInterface* get_interface_static(
238
IInterface* iinterface,
const
Uuid& interface_id)
239
{
240
if
( interface_id ==
IID
()) {
241
iinterface->
retain
();
242
return
iinterface;
243
}
244
return
0;
245
}
246
247
};
248
// end group mi_base_iinterface
250
251
}
// namespace base
252
253
}
// namespace mi
254
255
#endif // MI_BASE_IINTERFACE_H
5 April 2022, 20:40, rev.358266
© 2022 NVIDIA Corporation.
All rights reserved.