NVIDIA Iray API
 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, 2014 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 
96  virtual Sint32 set_reference( const char* name) = 0;
97 
99  virtual const base::IInterface* get_reference() const = 0;
100 
110  template <class T>
111  const T* get_reference() const
112  {
113  const base::IInterface* ptr_iinterface = get_reference();
114  if ( !ptr_iinterface)
115  return 0;
116  const T* ptr_T = static_cast<const T*>( ptr_iinterface->get_interface( typename T::IID()));
117  ptr_iinterface->release();
118  return ptr_T;
119  }
120 
122  virtual base::IInterface* get_reference() = 0;
123 
133  template <class T>
135  {
136  base::IInterface* ptr_iinterface = get_reference();
137  if ( !ptr_iinterface)
138  return 0;
139  T* ptr_T = static_cast<T*>( ptr_iinterface->get_interface( typename T::IID()));
140  ptr_iinterface->release();
141  return ptr_T;
142  }
143 
145  virtual const char* get_reference_name() const = 0;
146 
148  virtual const IData* get_value() const = 0;
149 
157  template<class T>
158  const T* get_value() const
159  {
160  const IData* ptr_idata = get_value();
161  if ( !ptr_idata)
162  return 0;
163  const T* ptr_T = static_cast<const T*>( ptr_idata->get_interface( typename T::IID()));
164  ptr_idata->release();
165  return ptr_T;
166  }
167 
169  virtual IData* get_value() = 0;
170 
178  template<class T>
180  {
181  IData* ptr_idata = get_value();
182  if ( !ptr_idata)
183  return 0;
184  T* ptr_T = static_cast<T*>( ptr_idata->get_interface( typename T::IID()));
185  ptr_idata->release();
186  return ptr_T;
187  }
188 };
189  // end group mi_neuray_simple_types
191 
192 } // namespace mi
193 
194 #endif // MI_NEURAYLIB_IATTACHABLE_H