NVIDIA Iray: Math API
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 1986, 2014 NVIDIA Corporation. All rights reserved.
3
//*****************************************************************************
6
//*****************************************************************************
7
8
#ifndef MI_BASE_IINTERFACE_H
9
#define MI_BASE_IINTERFACE_H
10
11
#include <
mi/base/types.h
>
12
#include <
mi/base/uuid.h
>
13
14
namespace
mi {
15
16
namespace
base {
17
37
// Forward declaration, see below for definition
38
class
IInterface;
39
103
class
IInterface
104
{
105
public
:
106
113
typedef
Uuid_t<0,0,0,0,0,0,0,0,0,0,0>
IID
;
114
118
static
bool
compare_iid
(
const
Uuid
& iid)
119
{
120
return
( iid ==
IID
());
121
}
122
129
virtual
Uint32
retain
()
const
= 0;
130
138
virtual
Uint32
release
()
const
= 0;
139
152
virtual
const
IInterface
*
get_interface
(
const
Uuid
& interface_id )
const
= 0;
153
169
template
<
class
T>
170
const
T*
get_interface
()
const
171
{
172
return
static_cast<
const
T*
>
(
get_interface
(
typename
T::IID()));
173
}
174
187
virtual
IInterface
*
get_interface
(
const
Uuid
& interface_id ) = 0;
188
204
template
<
class
T>
205
T*
get_interface
()
206
{
207
return
static_cast<
T*
>
(
get_interface
(
typename
T::IID()));
208
}
209
211
virtual
Uuid
get_iid
()
const
= 0;
212
213
protected
:
214
// Acquires a const interface.
215
//
216
// Static helper function for implementing #get_interface(const Uuid&). On #IInterface, the
217
// method terminates the recursive call chain.
218
//
219
// \param iinterface The interface to act on.
220
// \param interface_id Interface ID of the interface to acquire.
221
static
const
IInterface
* get_interface_static(
222
const
IInterface
* iinterface,
const
Uuid
& interface_id)
223
{
224
if
( interface_id ==
IID
()) {
225
iinterface->
retain
();
226
return
iinterface;
227
}
228
return
0;
229
}
230
231
// Acquires a mutable interface.
232
//
233
// Static helper function for implementing #get_interface(const Uuid&). On #IInterface, the
234
// method terminates the recursive call chain.
235
//
236
// \param iinterface The interface to act on.
237
// \param interface_id Interface ID of the interface to acquire.
238
static
IInterface* get_interface_static(
239
IInterface* iinterface,
const
Uuid& interface_id)
240
{
241
if
( interface_id ==
IID
()) {
242
iinterface->
retain
();
243
return
iinterface;
244
}
245
return
0;
246
}
247
248
};
249
// end group mi_base_iinterface
251
252
}
// namespace base
253
254
}
// namespace mi
255
256
#endif // MI_BASE_IINTERFACE_H
mi
base
iinterface.h
Generated on Tue Aug 12 2014 15:28:27. Build 221133.3991, Doxygen 1.8.4