Material Definition Language API nvidia_logo_transpbg.gif Up
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
iref.h
Go to the documentation of this file.
1 /***************************************************************************************************
2  * Copyright 2020 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 
12 namespace mi {
13 
18 class IRef :
23  public base::Interface_declare<0x3572250a,0x605e,0x4b6c,0xa0,0xc3,0xae,0xd5,0x7e,0x24,0x69,0x9b,
24  IData_simple>
25 {
26 public:
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 
82  virtual base::IInterface* get_reference() = 0;
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