MDL SDK API nvidia_logo_transpbg.gif Up
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
ifunction_definition.h
Go to the documentation of this file.
1 /***************************************************************************************************
2  * Copyright 2022 NVIDIA Corporation. All rights reserved.
3  **************************************************************************************************/
6 
7 #ifndef MI_NEURAYLIB_IFUNCTION_DEFINITION_H
8 #define MI_NEURAYLIB_IFUNCTION_DEFINITION_H
9 
10 #include <cstring>
11 
14 
15 namespace mi {
16 
17 namespace neuraylib {
18 
23 class IFunction_call;
24 class IMdl_execution_context;
25 
42 class IFunction_definition : public
43  mi::base::Interface_declare<0x3504744d,0xd45b,0x4a99,0xb6,0x21,0x10,0x9e,0xd5,0xcb,0x36,0xc1,
44  neuraylib::IScene_element>
45 {
46 public:
47 
54  enum Semantics
55  {
56  DS_UNKNOWN = 0,
57 
68 
69  // Unary operators
70 
72  DS_UNARY_FIRST = DS_BITWISE_COMPLEMENT,
73  DS_OPERATOR_FIRST = DS_UNARY_FIRST,
81  DS_CAST,
83  DS_UNARY_LAST = DS_CAST,
84 
85  // Binary operators
86 
88  DS_BINARY_FIRST = DS_SELECT,
123  DS_BINARY_LAST = DS_SEQUENCE,
124 
125  // Ternary operator
126 
129  DS_OPERATOR_LAST = DS_TERNARY,
130 
131  // ::math module intrinsics
132 
134  DS_INTRINSIC_MATH_ABS = DS_INTRINSIC_MATH_FIRST,
199  DS_INTRINSIC_MATH_LAST = DS_INTRINSIC_MATH_DY,
200 
201  // ::state module intrinsics
202 
204  DS_INTRINSIC_STATE_FIRST = DS_INTRINSIC_STATE_POSITION,
229  DS_INTRINSIC_STATE_LAST = DS_INTRINSIC_STATE_WAVELENGTH_MAX,
230 
231  // ::tex module intrinsics
232 
234  DS_INTRINSIC_TEX_FIRST = DS_INTRINSIC_TEX_WIDTH,
254  DS_INTRINSIC_TEX_LAST = DS_INTRINSIC_TEX_GRID_TO_OBJECT_SPACE,
255 
256  // ::df module intrinsics
257 
260  DS_INTRINSIC_DF_FIRST = DS_INTRINSIC_DF_DIFFUSE_REFLECTION_BSDF,
308  DS_INTRINSIC_DF_LAST = DS_INTRINSIC_DF_COLOR_UNBOUNDED_MIX,
309 
310 #ifndef MDL_SOURCE_RELEASE
311  // ::nvidia::df module intrinsics
312 
315  DS_INTRINSIC_NVIDIA_DF_FIRST = DS_INTRINSIC_NVIDIA_DF_ASHIKHMIN_SHIRLEY_GLOSSY_BSDF,
342  DS_INTRINSIC_NVIDIA_DF_LAST = DS_INTRINSIC_NVIDIA_DF_THIN_FILM_LAYER,
343 #endif
344 
345  // ::scene module intrinsics
346 
349  DS_INTRINSIC_SCENE_FIRST = DS_INTRINSIC_SCENE_DATA_ISVALID,
386  DS_INTRINSIC_SCENE_LAST = DS_INTRINSIC_SCENE_DATA_LOOKUP_UNIFORM_COLOR,
387 
388  // ::debug module intrinsics
389 
391  DS_INTRINSIC_DEBUG_FIRST = DS_INTRINSIC_DEBUG_BREAKPOINT,
394  DS_INTRINSIC_DEBUG_LAST = DS_INTRINSIC_DEBUG_PRINT,
395 
396  // DAG backend intrinsics
397 
400  DS_INTRINSIC_DAG_FIRST = DS_INTRINSIC_DAG_FIELD_ACCESS,
405  DS_INTRINSIC_DAG_LAST = DS_INTRINSIC_DAG_ARRAY_LENGTH,
406 
407  DS_FORCE_32_BIT = 0xffffffffU // Undocumented, for alignment only.
408  };
409 
413  virtual const char* get_module() const = 0;
414 
421  virtual const char* get_mdl_name() const = 0;
422 
424  virtual const char* get_mdl_module_name() const = 0;
425 
432  virtual const char* get_mdl_simple_name() const = 0;
433 
446  virtual const char* get_mdl_parameter_type_name( Size index) const = 0;
447 
450  virtual const char* get_prototype() const = 0;
451 
460  virtual void get_mdl_version( Mdl_version& since, Mdl_version& removed) const = 0;
461 
463  virtual Semantics get_semantic() const = 0;
464 
468  inline bool is_array_constructor() const { return strcmp( get_mdl_name(), "T[](...)") == 0; }
469 
471  virtual bool is_exported() const = 0;
472 
478  virtual bool is_uniform() const = 0;
479 
484  virtual bool is_material() const = 0;
485 
489  virtual const IType* get_return_type() const = 0;
490 
501  template<class T>
502  const T* get_return_type() const
503  {
504  const IType* ptr_itype = get_return_type();
505  if ( !ptr_itype)
506  return 0;
507  const T* ptr_T = static_cast<const T*>( ptr_itype->get_interface( typename T::IID()));
508  ptr_itype->release();
509  return ptr_T;
510  }
511 
513  virtual Size get_parameter_count() const = 0;
514 
519  virtual const char* get_parameter_name( Size index) const = 0;
520 
525  virtual Size get_parameter_index( const char* name) const = 0;
526 
528  virtual const IType_list* get_parameter_types() const = 0;
529 
535  virtual const IExpression_list* get_defaults() const = 0;
536 
543  virtual const IExpression_list* get_enable_if_conditions() const = 0;
544 
551  virtual Size get_enable_if_users( Size index) const = 0;
552 
560  virtual Size get_enable_if_user( Size index, Size u_index) const = 0;
561 
564  virtual const IAnnotation_block* get_annotations() const = 0;
565 
568  virtual const IAnnotation_block* get_return_annotations() const = 0;
569 
576  virtual const IAnnotation_list* get_parameter_annotations() const = 0;
577 
585  virtual const char* get_thumbnail() const = 0;
586 
598  virtual bool is_valid( IMdl_execution_context* context) const = 0;
599 
610  virtual const IExpression* get_body() const = 0;
611 
613  virtual Size get_temporary_count() const = 0;
614 
620  virtual const IExpression* get_temporary( Size index) const = 0;
621 
632  virtual const char* get_temporary_name( Size index) const = 0;
633 
646  template<class T>
647  const T* get_temporary( Size index) const
648  {
649  const IExpression* ptr_iexpression = get_temporary( index);
650  if ( !ptr_iexpression)
651  return 0;
652  const T* ptr_T = static_cast<const T*>( ptr_iexpression->get_interface( typename T::IID()));
653  ptr_iexpression->release();
654  return ptr_T;
655  }
656 
690  const IExpression_list* arguments, Sint32* errors = 0) const = 0;
691 };
692 
694  // end group mi_neuray_mdl_elements
696 
697 } // namespace neuraylib
698 
699 } // namespace mi
700 
701 #endif // MI_NEURAYLIB_IFUNCTION_DEFINITION_H