NVIDIA Iray API Home  Up
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
iattachable.h
Go to the documentation of this file.
1 //*****************************************************************************
2 // Copyright 1986, 2016 NVIDIA Corporation. All rights reserved.
3 //*****************************************************************************
6 //*****************************************************************************
7 
8 #ifndef MI_NEURAYLIB_IATTACHABLE_H
9 #define MI_NEURAYLIB_IATTACHABLE_H
10 
11 #include <mi/neuraylib/idata.h>
12 
13 namespace mi {
14 
19 class IAttachable :
41  public base::Interface_declare<0x5e7a28b7,0x38aa,0x45ac,0x98,0x65,0x97,0xac,0xcd,0x81,0xc4,0x0e,
42  IData_simple>
43 {
44 public:
70  virtual Sint32 set_reference( const base::IInterface* db_element) = 0;
71 
97  virtual Sint32 set_reference( const char* name) = 0;
98 
100  virtual const base::IInterface* get_reference() const = 0;
101 
111  template <class T>
112  const T* get_reference() const
113  {
114  const base::IInterface* ptr_iinterface = get_reference();
115  if ( !ptr_iinterface)
116  return 0;
117  const T* ptr_T = static_cast<const T*>( ptr_iinterface->get_interface( typename T::IID()));
118  ptr_iinterface->release();
119  return ptr_T;
120  }
121 
123  virtual base::IInterface* get_reference() = 0;
124 
134  template <class T>
136  {
137  base::IInterface* ptr_iinterface = get_reference();
138  if ( !ptr_iinterface)
139  return 0;
140  T* ptr_T = static_cast<T*>( ptr_iinterface->get_interface( typename T::IID()));
141  ptr_iinterface->release();
142  return ptr_T;
143  }
144 
146  virtual const char* get_reference_name() const = 0;
147 
149  virtual const IData* get_value() const = 0;
150 
158  template<class T>
159  const T* get_value() const
160  {
161  const IData* ptr_idata = get_value();
162  if ( !ptr_idata)
163  return 0;
164  const T* ptr_T = static_cast<const T*>( ptr_idata->get_interface( typename T::IID()));
165  ptr_idata->release();
166  return ptr_T;
167  }
168 
170  virtual IData* get_value() = 0;
171 
179  template<class T>
181  {
182  IData* ptr_idata = get_value();
183  if ( !ptr_idata)
184  return 0;
185  T* ptr_T = static_cast<T*>( ptr_idata->get_interface( typename T::IID()));
186  ptr_idata->release();
187  return ptr_T;
188  }
189 };
190  // end group mi_neuray_simple_types
192 
193 } // namespace mi
194 
195 #endif // MI_NEURAYLIB_IATTACHABLE_H