Material Definition Language API nvidia_logo_transpbg.gif Up
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
itype.h
Go to the documentation of this file.
1 /***************************************************************************************************
2  * Copyright 2019 NVIDIA Corporation. All rights reserved.
3  **************************************************************************************************/
6 
7 #ifndef MI_NEURAYLIB_ITYPE_H
8 #define MI_NEURAYLIB_ITYPE_H
9 
11 
12 namespace mi {
13 
14 class IString;
15 
16 namespace neuraylib {
17 
43 class IAnnotation_block;
44 
48 class IType : public
49  mi::base::Interface_declare<0x242af675,0xeaa2,0x48b7,0x81,0x63,0xba,0x06,0xa5,0xfb,0x68,0xf0>
50 {
51 public:
53  enum Kind {
90  // Undocumented, for alignment only.
91  TK_FORCE_32_BIT = 0xffffffffU
92  };
93 
95  enum Modifier {
96  MK_NONE = 0,
97  MK_UNIFORM = 2,
98  MK_VARYING = 4,
99  MK_FORCE_32_BIT // Undocumented, for alignment only.
100  };
101 
103  virtual Kind get_kind() const = 0;
104 
112  virtual Uint32 get_all_type_modifiers() const = 0;
113 
119  virtual const IType* skip_all_type_aliases() const = 0;
120 };
121 
122 mi_static_assert( sizeof( IType::Kind) == sizeof( Uint32));
123 mi_static_assert( sizeof( IType::Modifier) == sizeof( Uint32));
124 
129 class IType_alias : public
130  mi::base::Interface_declare<0x69d8c70a,0xdfda,0x4e8e,0xaa,0x09,0x12,0x1f,0xa9,0x78,0xc6,0x6a,
131  neuraylib::IType>
132 {
133 public:
135  static const Kind s_kind = TK_ALIAS;
136 
138  virtual const IType* get_aliased_type() const = 0;
139 
141  virtual Uint32 get_type_modifiers() const = 0;
142 
144  virtual const char* get_symbol() const = 0;
145 };
146 
148 class IType_atomic : public
149  mi::base::Interface_declare<0x9d5f9116,0x3896,0x45c8,0xb4,0x5a,0x8b,0x03,0x84,0x49,0x0a,0x77,
150  neuraylib::IType>
151 {
152 };
153 
155 class IType_bool : public
156  mi::base::Interface_declare<0x831d8a38,0x26d3,0x4fd2,0xa7,0xf7,0x15,0xc2,0xa5,0x20,0x76,0x6c,
157  neuraylib::IType_atomic>
158 {
159 public:
161  static const Kind s_kind = TK_BOOL;
162 };
163 
165 class IType_int : public
166  mi::base::Interface_declare<0xbbad021c,0xbfe5,0x45de,0xaf,0x66,0xfd,0xe8,0x45,0xbe,0x48,0x49,
167  neuraylib::IType_atomic>
168 {
169 public:
171  static const Kind s_kind = TK_INT;
172 };
173 
175 class IType_enum : public
176  mi::base::Interface_declare<0x0e5b167c,0x9c3e,0x48bf,0xb5,0xfd,0x37,0x96,0xaa,0x47,0xaf,0xd1,
177  neuraylib::IType_atomic>
178 {
179 public:
182  EID_USER = -1,
185  EID_FORCE_32_BIT = 0x7fffffff // Undocumented, for alignment only.
186  };
187 
189  static const Kind s_kind = TK_ENUM;
190 
192  virtual const char* get_symbol() const = 0;
193 
195  virtual Size get_size() const = 0;
196 
201  virtual const char* get_value_name( Size index) const = 0;
202 
210  virtual Sint32 get_value_code( Size index, Sint32* errors = 0) const = 0;
211 
216  virtual Size find_value( const char* name) const = 0;
217 
222  virtual Size find_value( Sint32 code) const = 0;
223 
225  virtual Predefined_id get_predefined_id() const = 0;
226 
231  virtual const IAnnotation_block* get_annotations() const = 0;
232 
238  virtual const IAnnotation_block* get_value_annotations( Size index) const = 0;
239 };
240 
241 mi_static_assert( sizeof( IType_enum::Predefined_id) == sizeof( Uint32));
242 
244 class IType_float : public
245  mi::base::Interface_declare<0x613711b3,0x41f2,0x44a9,0xbb,0x78,0x43,0xe2,0x41,0x64,0xb3,0xda,
246  neuraylib::IType_atomic>
247 {
248 public:
250  static const Kind s_kind = TK_FLOAT;
251 };
252 
254 class IType_double : public
255  mi::base::Interface_declare<0xc381508b,0x7945,0x4c70,0x8a,0x20,0x57,0xd5,0x2b,0x36,0x35,0x40,
256  neuraylib::IType_atomic>
257 {
258 public:
260  static const Kind s_kind = TK_DOUBLE;
261 };
262 
264 class IType_string : public
265  mi::base::Interface_declare<0x4b4629bc,0xa2ce,0x4008,0xba,0x76,0xf6,0x4d,0x60,0x76,0x0a,0x85,
266  neuraylib::IType_atomic>
267 {
268 public:
270  static const Kind s_kind = TK_STRING;
271 };
272 
274 class IType_compound : public
275  mi::base::Interface_declare<0xc9ca497f,0xc38b,0x411f,0xa8,0x16,0xa7,0xd8,0x23,0x28,0xa5,0x40,
276  neuraylib::IType>
277 {
278 public:
280  virtual const IType* get_component_type( Size index) const = 0;
281 
283  virtual Size get_size() const = 0;
284 };
285 
290 class IType_vector : public
291  mi::base::Interface_declare<0x412a8a91,0x9062,0x46fd,0xaa,0xcf,0x46,0xbd,0xb3,0xde,0x5b,0x9c,
292  neuraylib::IType_compound>
293 {
294 public:
296  static const Kind s_kind = TK_VECTOR;
297 
304  virtual const IType_atomic* get_element_type() const = 0;
305 };
306 
313 class IType_matrix : public
314  mi::base::Interface_declare<0x6b76570e,0x51b2,0x4e9b,0x9f,0xe7,0xda,0x03,0x1c,0x37,0xbc,0x75,
315  neuraylib::IType_compound>
316 {
317 public:
319  static const Kind s_kind = TK_MATRIX;
320 
322  virtual const IType_vector* get_element_type() const = 0;
323 };
324 
326 class IType_color : public
327  mi::base::Interface_declare<0xedb16770,0xdf70,0x4def,0x83,0xa5,0xc4,0x4f,0xcd,0x09,0x47,0x0f,
328  neuraylib::IType_compound>
329 {
330 public:
332  static const Kind s_kind = TK_COLOR;
333 };
334 
336 class IType_array : public
337  mi::base::Interface_declare<0x21ab6abe,0x0e26,0x40da,0xa1,0x98,0x42,0xc0,0x89,0x71,0x5d,0x2a,
338  neuraylib::IType_compound>
339 {
340 public:
342  static const Kind s_kind = TK_ARRAY;
343 
345  virtual const IType* get_element_type() const = 0;
346 
348  virtual bool is_immediate_sized() const = 0;
349 
351  virtual Size get_size() const = 0;
352 
357  virtual const char* get_deferred_size() const = 0;
358 };
359 
361 class IType_struct : public
362  mi::base::Interface_declare<0x19566cb2,0x0b5d,0x41ca,0xa0,0x31,0x96,0xe2,0x9a,0xd4,0xc3,0x1a,
363  neuraylib::IType_compound>
364 {
365 public:
368  SID_USER = -1,
374  SID_FORCE_32_BIT = 0x7fffffff // Undocumented, for alignment only.
375  };
376 
378  static const Kind s_kind = TK_STRUCT;
379 
381  virtual const char* get_symbol() const = 0;
382 
387  virtual const IType* get_field_type( Size index) const = 0;
388 
393  virtual const char* get_field_name( Size index) const = 0;
394 
399  virtual Size find_field( const char* name) const = 0;
400 
402  virtual Predefined_id get_predefined_id() const = 0;
403 
408  virtual const IAnnotation_block* get_annotations() const = 0;
409 
415  virtual const IAnnotation_block* get_field_annotations( Size index) const = 0;
416 };
417 
419 
421 class IType_reference : public
422  mi::base::Interface_declare<0x3e12cdec,0xdaba,0x460c,0x9e,0x8a,0x21,0x4c,0x43,0x9a,0x1a,0x90,
423  neuraylib::IType>
424 {
425 };
426 
428 class IType_resource : public
429  mi::base::Interface_declare<0x142f5bea,0x139e,0x42e4,0xb1,0x1c,0xb3,0x4d,0xd8,0xe3,0xd9,0x8d,
430  neuraylib::IType_reference>
431 {
432 };
433 
435 class IType_texture : public
436  mi::base::Interface_declare<0x2f11253f,0xb8ac,0x4b7d,0x8d,0xd6,0x43,0x66,0xf5,0x97,0xd0,0x93,
437  neuraylib::IType_resource>
438 {
439 public:
441  static const Kind s_kind = TK_TEXTURE;
442 
444  enum Shape {
445  TS_2D = 0,
446  TS_3D = 1,
447  TS_CUBE = 2,
448  TS_PTEX = 3,
449  TS_FORCE_32_BIT = 0xffffffffU // Undocumented, for alignment only.
450  };
451 
453  virtual Shape get_shape() const = 0;
454 };
455 
456 mi_static_assert( sizeof( IType_texture::Shape) == sizeof( Uint32));
457 
459 class IType_light_profile : public
460  mi::base::Interface_declare<0x11b80cd8,0x14aa,0x4dfa,0x8b,0xf6,0x0e,0x56,0x0f,0x10,0x9c,0x37,
461  neuraylib::IType_resource>
462 {
463 public:
465  static const Kind s_kind = TK_LIGHT_PROFILE;
466 };
467 
470  mi::base::Interface_declare<0xf061d204,0xc649,0x4a6b,0xb6,0x2d,0x67,0xe6,0x47,0x53,0xa9,0xda,
471  neuraylib::IType_resource>
472 {
473 public:
476 };
477 
479 class IType_df : public
480  mi::base::Interface_declare<0xf4bcba08,0x7777,0x4662,0x8e,0x29,0x67,0xe1,0x52,0xac,0x05,0x3e,
481  neuraylib::IType_reference>
482 {
483 };
484 
486 class IType_bsdf : public
487  mi::base::Interface_declare<0x6542a02c,0xe1d2,0x485d,0x9a,0x51,0x7b,0xed,0xff,0x7f,0x24,0x7b,
488  neuraylib::IType_df>
489 {
490 public:
492  static const Kind s_kind = TK_BSDF;
493 };
494 
496 class IType_edf : public
497  mi::base::Interface_declare<0x3e3ce697,0xa2a7,0x43ef,0xa2,0xec,0x52,0x5a,0x4c,0x27,0x8f,0xeb,
498  neuraylib::IType_df>
499 {
500 public:
502  static const Kind s_kind = TK_EDF;
503 };
504 
506 class IType_vdf : public
507  mi::base::Interface_declare<0x44782b21,0x9e60,0x40b2,0xba,0xae,0x41,0x74,0xc9,0x98,0xe1,0x86,
508  neuraylib::IType_df>
509 {
510 public:
512  static const Kind s_kind = TK_VDF;
513 };
514 
518 class IType_list : public
519  mi::base::Interface_declare<0x68a97390,0x22ea,0x4f03,0xa5,0xb5,0x5c,0x18,0x32,0x38,0x28,0x91>
520 {
521 public:
523  virtual Size get_size() const = 0;
524 
526  virtual Size get_index( const char* name) const = 0;
527 
529  virtual const char* get_name( Size index) const = 0;
530 
532  virtual const IType* get_type( Size index) const = 0;
533 
535  template <class T>
536  const T* get_type( Size index) const
537  {
538  const IType* ptr_type = get_type( index);
539  if( !ptr_type)
540  return 0;
541  const T* ptr_T = static_cast<const T*>( ptr_type->get_interface( typename T::IID()));
542  ptr_type->release();
543  return ptr_T;
544  }
545 
547  virtual const IType* get_type( const char* name) const = 0;
548 
550  template <class T>
551  const T* get_type( const char* name) const
552  {
553  const IType* ptr_type = get_type( name);
554  if( !ptr_type)
555  return 0;
556  const T* ptr_T = static_cast<const T*>( ptr_type->get_interface( typename T::IID()));
557  ptr_type->release();
558  return ptr_T;
559  }
560 
566  virtual Sint32 set_type( Size index, const IType* type) = 0;
567 
573  virtual Sint32 set_type( const char* name, const IType* type) = 0;
574 
580  virtual Sint32 add_type( const char* name, const IType* type) = 0;
581 };
582 
586 class IType_factory : public
587  mi::base::Interface_declare<0x353803c0,0x74a6,0x48ac,0xab,0xa1,0xe4,0x25,0x42,0x1d,0xa1,0xbc>
588 {
589 public:
591  virtual const IType_alias* create_alias(
592  const IType* type, Uint32 modifiers, const char* symbol) const = 0;
593 
595  virtual const IType_bool* create_bool() const = 0;
596 
598  virtual const IType_int* create_int() const = 0;
599 
601  virtual const IType_enum* create_enum( const char* symbol) const = 0;
602 
604  virtual const IType_float* create_float() const = 0;
605 
607  virtual const IType_double* create_double() const = 0;
608 
610  virtual const IType_string* create_string() const = 0;
611 
619  virtual const IType_vector* create_vector(
620  const IType_atomic* element_type, Size size) const = 0;
621 
628  virtual const IType_matrix* create_matrix(
629  const IType_vector* column_type, Size columns) const = 0;
630 
632  virtual const IType_color* create_color() const = 0;
633 
636  const IType* element_type, Size size) const = 0;
637 
640  const IType* element_type, const char* size) const = 0;
641 
643  virtual const IType_struct* create_struct( const char* symbol) const = 0;
644 
646  virtual const IType_texture* create_texture( IType_texture::Shape shape) const = 0;
647 
649  virtual const IType_light_profile* create_light_profile() const = 0;
650 
652  virtual const IType_bsdf_measurement* create_bsdf_measurement() const = 0;
653 
655  virtual const IType_bsdf* create_bsdf() const = 0;
656 
658  virtual const IType_edf* create_edf() const = 0;
659 
661  virtual const IType_vdf* create_vdf() const = 0;
662 
664  virtual IType_list* create_type_list() const = 0;
665 
667  virtual const IType_enum* get_predefined_enum( IType_enum::Predefined_id id) const = 0;
668 
670  virtual const IType_struct* get_predefined_struct( IType_struct::Predefined_id id) const = 0;
671 
695  virtual Sint32 compare( const IType* lhs, const IType* rhs) const = 0;
696 
710  virtual Sint32 compare( const IType_list* lhs, const IType_list* rhs) const = 0;
711 
721  virtual const IString* dump( const IType* type, Size depth = 0) const = 0;
722 
732  virtual const IString* dump( const IType_list* list, Size depth = 0) const = 0;
733 };
734  // end group mi_neuray_mdl_types
736 
737 } // namespace neuraylib
738 
739 } // namespace mi
740 
741 #endif // MI_NEURAYLIB_ITYPE_H