Material Definition Language API nvidia_logo_transpbg.gif Up
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
iarray.h
Go to the documentation of this file.
1 /***************************************************************************************************
2  * Copyright 2020 NVIDIA Corporation. All rights reserved.
3  **************************************************************************************************/
6 
7 #ifndef MI_NEURAYLIB_IARRAY_H
8 #define MI_NEURAYLIB_IARRAY_H
9 
10 #include <mi/neuraylib/idata.h>
11 
12 namespace mi {
13 
18 class IArray :
35  public base::Interface_declare<0x329db537,0x9892,0x488c,0xa2,0xf4,0xf5,0x37,0x1a,0x35,0xcf,0x39,
36  IData_collection>
37 {
38 public:
42  virtual Size get_length() const = 0;
43 
49  virtual const base::IInterface* get_element( Size index) const = 0;
50 
62  template<class T>
63  const T* get_element( Size index) const
64  {
65  const base::IInterface* ptr_iinterface = get_element( index);
66  if ( !ptr_iinterface)
67  return 0;
68  const T* ptr_T = static_cast<const T*>( ptr_iinterface->get_interface( typename T::IID()));
69  ptr_iinterface->release();
70  return ptr_T;
71  }
72 
78  virtual base::IInterface* get_element( Size index) = 0;
79 
91  template<class T>
92  T* get_element( Size index)
93  {
94  base::IInterface* ptr_iinterface = get_element( index);
95  if ( !ptr_iinterface)
96  return 0;
97  T* ptr_T = static_cast<T*>( ptr_iinterface->get_interface( typename T::IID()));
98  ptr_iinterface->release();
99  return ptr_T;
100  }
101 
113  virtual Sint32 set_element( Size index, base::IInterface* element) = 0;
114 
118  virtual bool empty() const = 0;
119 };
120  // end group mi_neuray_collections
122 
123 } // namespace mi
124 
125 #endif // MI_NEURAYLIB_IARRAY_H