NVIDIA Iray API
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
iref.h
Go to the documentation of this file.
1 //*****************************************************************************
2 // Copyright 1986, 2014 NVIDIA Corporation. All rights reserved.
3 //*****************************************************************************
6 //*****************************************************************************
7 
8 #ifndef MI_NEURAYLIB_IREF_H
9 #define MI_NEURAYLIB_IREF_H
10 
11 #include <mi/neuraylib/idata.h>
12 
13 namespace mi {
14 
19 class IRef :
43  public base::Interface_declare<0x3572250a,0x605e,0x4b6c,0xa0,0xc3,0xae,0xd5,0x7e,0x24,0x69,0x9b,
44  IData_simple>
45 {
46 public:
63  virtual Sint32 set_reference( const base::IInterface* db_element) = 0;
64 
80  virtual Sint32 set_reference( const char* name) = 0;
81 
83  virtual const base::IInterface* get_reference() const = 0;
84 
94  template <class T>
95  const T* get_reference() const
96  {
97  const base::IInterface* ptr_iinterface = get_reference();
98  if ( !ptr_iinterface)
99  return 0;
100  const T* ptr_T = static_cast<const T*>( ptr_iinterface->get_interface( typename T::IID()));
101  ptr_iinterface->release();
102  return ptr_T;
103  }
104 
106  virtual base::IInterface* get_reference() = 0;
107 
117  template <class T>
119  {
120  base::IInterface* ptr_iinterface = get_reference();
121  if ( !ptr_iinterface)
122  return 0;
123  T* ptr_T = static_cast<T*>( ptr_iinterface->get_interface( typename T::IID()));
124  ptr_iinterface->release();
125  return ptr_T;
126  }
127 
129  virtual const char* get_reference_name() const = 0;
130 };
131  // end group mi_neuray_simple_types
133 
134 } // namespace mi
135 
136 #endif // MI_NEURAYLIB_IREF_H