MDL SDK API nvidia_logo_transpbg.gif Up
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
iexpression.h
Go to the documentation of this file.
1 /***************************************************************************************************
2  * Copyright 2022 NVIDIA Corporation. All rights reserved.
3  **************************************************************************************************/
6 
7 #ifndef MI_NEURAYLIB_IEXPRESSION_H
8 #define MI_NEURAYLIB_IEXPRESSION_H
9 
10 #include <mi/neuraylib/ivalue.h>
11 
12 namespace mi {
13 
14 class IString;
15 
16 namespace neuraylib {
17 
18 class IAnnotation;
19 class IAnnotation_block;
20 class IExpression_list;
21 
26 enum Mdl_version {
37  MDL_VERSION_INVALID = 0xffffffffU,
38  MDL_VERSION_FORCE_32_BIT = 0xffffffffU // Undocumented, for alignment only
39 };
40 
44 class IExpression : public
45  mi::base::Interface_declare<0x0f4a7542,0x9b27,0x4924,0xbd,0x8d,0x82,0xe3,0xa9,0xa7,0xa9,0xd6>
46 {
47 public:
49  enum Kind {
60  // Undocumented, for alignment only.
61  EK_FORCE_32_BIT = 0xffffffffU
62  };
63 
65  virtual Kind get_kind() const = 0;
66 
68  virtual const IType* get_type() const = 0;
69 
71  template <class T>
72  const T* get_type() const
73  {
74  const IType* ptr_type = get_type();
75  if( !ptr_type)
76  return 0;
77  const T* ptr_T = static_cast<const T*>( ptr_type->get_interface( typename T::IID()));
78  ptr_type->release();
79  return ptr_T;
80  }
81 };
82 
83 mi_static_assert( sizeof( IExpression::Kind) == sizeof( Uint32));
84 
88 class IExpression_constant : public
89  mi::base::Interface_declare<0x9da8d465,0x4058,0x46cb,0x83,0x6e,0x0e,0x38,0xa6,0x7f,0xcd,0xef,
90  neuraylib::IExpression>
91 {
92 public:
94  static const Kind s_kind = EK_CONSTANT;
95 
97  virtual const IValue* get_value() const = 0;
98 
100  template <class T>
101  const T* get_value() const
102  {
103  const IValue* ptr_value = get_value();
104  if( !ptr_value)
105  return 0;
106  const T* ptr_T = static_cast<const T*>( ptr_value->get_interface( typename T::IID()));
107  ptr_value->release();
108  return ptr_T;
109  }
110 
112  virtual IValue* get_value() = 0;
113 
115  template <class T>
117  {
118  IValue* ptr_value = get_value();
119  if( !ptr_value)
120  return 0;
121  T* ptr_T = static_cast<T*>( ptr_value->get_interface( typename T::IID()));
122  ptr_value->release();
123  return ptr_T;
124  }
125 
132  virtual Sint32 set_value( IValue* value) = 0;
133 };
134 
143 class IExpression_call : public
144  mi::base::Interface_declare<0xcf625aec,0x8eb8,0x4743,0x9f,0xf6,0x76,0x82,0x2c,0x02,0x54,0xa3,
145  neuraylib::IExpression>
146 {
147 public:
149  static const Kind s_kind = EK_CALL;
150 
152  virtual const char* get_call() const = 0;
153 
168  virtual Sint32 set_call( const char* name) = 0;
169 };
170 
174 class IExpression_parameter : public
175  mi::base::Interface_declare<0x206c4319,0x0b53,0x45a7,0x86,0x07,0x29,0x98,0xb3,0x44,0x7f,0xaa,
176  neuraylib::IExpression>
177 {
178 public:
180  static const Kind s_kind = EK_PARAMETER;
181 
183  virtual Size get_index() const = 0;
184 
186  virtual void set_index( Size index) = 0;
187 };
188 
198  mi::base::Interface_declare<0x9253c9d6,0xe162,0x4234,0xab,0x91,0x54,0xc1,0xe4,0x87,0x39,0x66,
199  neuraylib::IExpression>
200 {
201 public:
203  static const Kind s_kind = EK_DIRECT_CALL;
204 
206  virtual const char* get_definition() const = 0;
207 
209  virtual const IExpression_list* get_arguments() const = 0;
210 };
211 
216 class IExpression_temporary : public
217  mi::base::Interface_declare<0xd91f484b,0xdbf8,0x4585,0x9d,0xab,0xba,0xd9,0x91,0x7f,0xe1,0x4c,
218  neuraylib::IExpression>
219 {
220 public:
222  static const Kind s_kind = EK_TEMPORARY;
223 
225  virtual Size get_index() const = 0;
226 
228  virtual void set_index( Size index) = 0;
229 };
230 
235 class IExpression_list : public
236  mi::base::Interface_declare<0x98ce8e89,0x9f23,0x45ec,0xa7,0xce,0x85,0x78,0x48,0x14,0x85,0x23>
237 {
238 public:
240  virtual Size get_size() const = 0;
241 
243  virtual Size get_index( const char* name) const = 0;
244 
246  virtual const char* get_name( Size index) const = 0;
247 
249  virtual const IExpression* get_expression( Size index) const = 0;
250 
252  template <class T>
253  const T* get_expression( Size index) const
254  {
255  const IExpression* ptr_expression = get_expression( index);
256  if( !ptr_expression)
257  return 0;
258  const T* ptr_T = static_cast<const T*>( ptr_expression->get_interface( typename T::IID()));
259  ptr_expression->release();
260  return ptr_T;
261  }
262 
264  virtual const IExpression* get_expression( const char* name) const = 0;
265 
267  template <class T>
268  const T* get_expression( const char* name) const
269  {
270  const IExpression* ptr_expression = get_expression( name);
271  if( !ptr_expression)
272  return 0;
273  const T* ptr_T = static_cast<const T*>( ptr_expression->get_interface( typename T::IID()));
274  ptr_expression->release();
275  return ptr_T;
276  }
277 
283  virtual Sint32 set_expression( Size index, const IExpression* expression) = 0;
284 
290  virtual Sint32 set_expression( const char* name, const IExpression* expression) = 0;
291 
297  virtual Sint32 add_expression( const char* name, const IExpression* expression) = 0;
298 };
299 
303  mi::base::Interface_declare<0xa453318b,0xe056,0x4521,0x9f,0x3c,0x9d,0x5c,0x3,0x23,0x5f,0xb7>
304 {
305 public:
306 
312  {
314 
317  AS_ANNOTATION_FIRST = AS_INTRINSIC_ANNOTATION,
324 
348 
349  AS_ANNOTATION_LAST = AS_ORIGIN_ANNOTATION,
350  AS_FORCE_32_BIT = 0xffffffffU // Undocumented, for alignment only.
351  };
352 
356  virtual const char* get_module() const = 0;
357 
359  virtual const char* get_name() const = 0;
360 
362  virtual const char* get_mdl_module_name() const = 0;
363 
370  virtual const char* get_mdl_simple_name() const = 0;
371 
380  virtual const char* get_mdl_parameter_type_name( Size index) const = 0;
381 
383  virtual Semantics get_semantic() const = 0;
384 
386  virtual bool is_exported() const = 0;
387 
396  virtual void get_mdl_version( Mdl_version& since, Mdl_version& removed) const = 0;
397 
399  virtual Size get_parameter_count() const = 0;
400 
406  virtual const char* get_parameter_name( Size index) const = 0;
407 
413  virtual Size get_parameter_index( const char* name) const = 0;
414 
416  virtual const IType_list* get_parameter_types() const = 0;
417 
419  virtual const IExpression_list* get_defaults() const = 0;
420 
423  virtual const IAnnotation_block* get_annotations() const = 0;
424 
431  virtual const IAnnotation* create_annotation( const IExpression_list* arguments) const = 0;
432 };
433 
435 
441 class IAnnotation : public
442  mi::base::Interface_declare<0xa9c652e7,0x952e,0x4887,0x93,0xb4,0x55,0xc8,0x66,0xd0,0x1a,0x1f>
443 {
444 public:
446  virtual const char* get_name() const = 0;
447 
449  virtual void set_name( const char* name) = 0;
450 
454  virtual const IExpression_list* get_arguments() const = 0;
455 
457  virtual const IAnnotation_definition* get_definition() const = 0;
458 };
459 
464 class IAnnotation_block : public
465  mi::base::Interface_declare<0x57b0ae97,0x0815,0x41e8,0x89,0xe7,0x16,0xa1,0x23,0x86,0x80,0x6e>
466 {
467 public:
469  virtual Size get_size() const = 0;
470 
472  virtual const IAnnotation* get_annotation( Size index) const = 0;
473 
479  virtual Sint32 set_annotation( Size index, const IAnnotation* annotation) = 0;
480 
485  virtual Sint32 add_annotation( IAnnotation* annotation) = 0;
486 };
487 
492 class IAnnotation_list : public
493  mi::base::Interface_declare<0x6c4663c2,0x112f,0x4eeb,0x81,0x60,0x41,0xa5,0xa6,0xfb,0x74,0x3c>
494 {
495 public:
497  virtual Size get_size() const = 0;
498 
500  virtual Size get_index( const char* name) const = 0;
501 
503  virtual const char* get_name( Size index) const = 0;
504 
506  virtual const IAnnotation_block* get_annotation_block( Size index) const = 0;
507 
509  virtual const IAnnotation_block* get_annotation_block( const char* name) const = 0;
510 
516  virtual Sint32 set_annotation_block( Size index, const IAnnotation_block* block) = 0;
517 
523  virtual Sint32 set_annotation_block( const char* name, const IAnnotation_block* block) = 0;
524 
530  virtual Sint32 add_annotation_block( const char* name, const IAnnotation_block* block) = 0;
531 };
532 
537 class IExpression_factory : public
538  mi::base::Interface_declare<0x9fd3b2d4,0xb5b8,0x4ccd,0x9b,0x5f,0x7b,0xd9,0x9d,0xeb,0x62,0x64>
539 {
540 public:
542  virtual IValue_factory* get_value_factory() const = 0;
543 
548  virtual IExpression_constant* create_constant( IValue* value) const = 0;
549 
554  virtual const IExpression_constant* create_constant( const IValue* value) const = 0;
555 
560  virtual IExpression_call* create_call( const char* name) const = 0;
561 
567  virtual IExpression_parameter* create_parameter( const IType* type, Size index) const = 0;
568 
608  const char* name, IExpression_list* arguments, Sint32* errors = 0) const = 0;
609 
611  virtual IExpression_list* create_expression_list() const = 0;
612 
617  const char* name, const IExpression_list* arguments) const = 0;
618 
620  virtual IAnnotation_block* create_annotation_block() const = 0;
621 
623  virtual IAnnotation_list* create_annotation_list() const = 0;
624 
630  virtual IExpression* clone( const IExpression* expr) const = 0;
631 
637  template <class T>
638  T* clone( const T* expr) const
639  {
640  IExpression* ptr_expr = clone( static_cast<const IExpression*>( expr));
641  if( !ptr_expr)
642  return 0;
643  T* ptr_T = static_cast<T*>( ptr_expr->get_interface( typename T::IID()));
644  ptr_expr->release();
645  return ptr_T;
646  }
647 
652  virtual IExpression_list* clone( const IExpression_list* expression_list) const = 0;
653 
672  // Undocumented, for alignment only
673  COMPARISON_OPTIONS_FORCE_32_BIT = 0xffffffffU
674  };
675 
676  mi_static_assert( sizeof( Comparison_options) == sizeof( mi::Uint32));
677 
709  virtual Sint32 compare(
710  const IExpression* lhs,
711  const IExpression* rhs,
712  Uint32 flags = 0,
713  Float64 epsilon = 0.0) const = 0;
714 
732  virtual Sint32 compare(
733  const IExpression_list* lhs,
734  const IExpression_list* rhs,
735  Uint32 flags = 0,
736  Float64 epsilon = 0.0) const = 0;
737 
746  virtual const IString* dump(
747  const IExpression* expr, const char* name, Size depth = 0) const = 0;
748 
758  virtual const IString* dump(
759  const IExpression_list* list, const char* name, Size depth = 0) const = 0;
760 
770  virtual const IString* dump(
771  const IAnnotation* annotation, const char* name, Size depth = 0) const = 0;
772 
782  virtual const IString* dump( const IAnnotation_block* block, const char* name, Size depth = 0)
783  const = 0;
784 
794  virtual const IString* dump( const IAnnotation_list* list, const char* name, Size depth = 0)
795  const = 0;
796 
823  virtual IExpression* create_cast(
824  IExpression* src_expr,
825  const IType* target_type,
826  const char* cast_db_name,
827  bool force_cast,
828  Sint32 *errors = 0) const = 0;
829 };
830  // end group mi_neuray_mdl_types
832 
833 } // namespace neuraylib
834 
835 } // namespace mi
836 
837 #endif // MI_NEURAYLIB_IEXPRESSION_H