DiCE API nvidia_logo_transpbg.gif Up
iref.h
Go to the documentation of this file.
1/***************************************************************************************************
2 * Copyright 2023 NVIDIA Corporation. All rights reserved.
3 **************************************************************************************************/
6
7#ifndef MI_NEURAYLIB_IREF_H
8#define MI_NEURAYLIB_IREF_H
9
10#include <mi/neuraylib/idata.h>
11
12namespace mi {
13
22class IRef :
23 public base::Interface_declare<0x3572250a,0x605e,0x4b6c,0xa0,0xc3,0xae,0xd5,0x7e,0x24,0x69,0x9b,
24 IData_simple>
25{
26public:
41 virtual Sint32 set_reference( const base::IInterface* db_element) = 0;
42
56 virtual Sint32 set_reference( const char* name) = 0;
57
59 virtual const base::IInterface* get_reference() const = 0;
60
70 template <class T>
71 const T* get_reference() const
72 {
73 const base::IInterface* ptr_iinterface = get_reference();
74 if ( !ptr_iinterface)
75 return 0;
76 const T* ptr_T = static_cast<const T*>( ptr_iinterface->get_interface( typename T::IID()));
77 ptr_iinterface->release();
78 return ptr_T;
79 }
80
83
93 template <class T>
95 {
96 base::IInterface* ptr_iinterface = get_reference();
97 if ( !ptr_iinterface)
98 return 0;
99 T* ptr_T = static_cast<T*>( ptr_iinterface->get_interface( typename T::IID()));
100 ptr_iinterface->release();
101 return ptr_T;
102 }
103
105 virtual const char* get_reference_name() const = 0;
106};
107 // end group mi_neuray_simple_types
109
110} // namespace mi
111
112#endif // MI_NEURAYLIB_IREF_H
A reference is an object that acts as a pointer to other database elements.
Definition: iref.h:25
virtual Sint32 set_reference(const char *name)=0
Sets the reference to the database element named name.
virtual base::IInterface * get_reference()=0
Returns the reference.
T * get_reference()
Returns the reference.
Definition: iref.h:94
const T * get_reference() const
Returns the reference.
Definition: iref.h:71
virtual const base::IInterface * get_reference() const =0
Returns the reference.
virtual const char * get_reference_name() const =0
Returns the name of the referenced element.
virtual Sint32 set_reference(const base::IInterface *db_element)=0
Sets the reference to db_element.
The basic extensible interface.
Definition: iinterface.h:103
Mixin class template for deriving new interface declarations.
Definition: interface_declare.h:43
virtual const IInterface * get_interface(const Uuid &interface_id) const =0
Acquires a const interface from another.
virtual Uint32 release() const =0
Decrements the reference count.
signed int Sint32
32-bit signed integer.
Definition: types.h:46
Types.
Common namespace for APIs of NVIDIA Advanced Rendering Center GmbH.
Definition: dice.h:89