Material Definition Language 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 2020 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 class IExpression : public
30  mi::base::Interface_declare<0x0f4a7542,0x9b27,0x4924,0xbd,0x8d,0x82,0xe3,0xa9,0xa7,0xa9,0xd6>
31 {
32 public:
34  enum Kind {
45  // Undocumented, for alignment only.
46  EK_FORCE_32_BIT = 0xffffffffU
47  };
48 
50  virtual Kind get_kind() const = 0;
51 
53  virtual const IType* get_type() const = 0;
54 
56  template <class T>
57  const T* get_type() const
58  {
59  const IType* ptr_type = get_type();
60  if( !ptr_type)
61  return 0;
62  const T* ptr_T = static_cast<const T*>( ptr_type->get_interface( typename T::IID()));
63  ptr_type->release();
64  return ptr_T;
65  }
66 };
67 
68 mi_static_assert( sizeof( IExpression::Kind) == sizeof( Uint32));
69 
75 class IExpression_constant : public
76  mi::base::Interface_declare<0x9da8d465,0x4058,0x46cb,0x83,0x6e,0x0e,0x38,0xa6,0x7f,0xcd,0xef,
77  neuraylib::IExpression>
78 {
79 public:
81  static const Kind s_kind = EK_CONSTANT;
82 
84  virtual const IValue* get_value() const = 0;
85 
87  template <class T>
88  const T* get_value() const
89  {
90  const IValue* ptr_value = get_value();
91  if( !ptr_value)
92  return 0;
93  const T* ptr_T = static_cast<const T*>( ptr_value->get_interface( typename T::IID()));
94  ptr_value->release();
95  return ptr_T;
96  }
97 
99  virtual IValue* get_value() = 0;
100 
102  template <class T>
104  {
105  IValue* ptr_value = get_value();
106  if( !ptr_value)
107  return 0;
108  T* ptr_T = static_cast<T*>( ptr_value->get_interface( typename T::IID()));
109  ptr_value->release();
110  return ptr_T;
111  }
112 
119  virtual Sint32 set_value( IValue* value) = 0;
120 };
121 
130 class IExpression_call : public
131  mi::base::Interface_declare<0xcf625aec,0x8eb8,0x4743,0x9f,0xf6,0x76,0x82,0x2c,0x02,0x54,0xa3,
132  neuraylib::IExpression>
133 {
134 public:
136  static const Kind s_kind = EK_CALL;
137 
139  virtual const char* get_call() const = 0;
140 
155  virtual Sint32 set_call( const char* name) = 0;
156 };
157 
161 class IExpression_parameter : public
162  mi::base::Interface_declare<0x206c4319,0x0b53,0x45a7,0x86,0x07,0x29,0x98,0xb3,0x44,0x7f,0xaa,
163  neuraylib::IExpression>
164 {
165 public:
167  static const Kind s_kind = EK_PARAMETER;
168 
170  virtual Size get_index() const = 0;
171 
173  virtual void set_index( Size index) = 0;
174 };
175 
184  mi::base::Interface_declare<0x9253c9d6,0xe162,0x4234,0xab,0x91,0x54,0xc1,0xe4,0x87,0x39,0x66,
185  neuraylib::IExpression>
186 {
187 public:
189  static const Kind s_kind = EK_DIRECT_CALL;
190 
192  virtual const char* get_definition() const = 0;
193 
195  virtual const IExpression_list* get_arguments() const = 0;
196 };
197 
201 class IExpression_temporary : public
202  mi::base::Interface_declare<0xd91f484b,0xdbf8,0x4585,0x9d,0xab,0xba,0xd9,0x91,0x7f,0xe1,0x4c,
203  neuraylib::IExpression>
204 {
205 public:
207  static const Kind s_kind = EK_TEMPORARY;
208 
210  virtual Size get_index() const = 0;
211 
213  virtual void set_index( Size index) = 0;
214 };
215 
220 class IExpression_list : public
221  mi::base::Interface_declare<0x98ce8e89,0x9f23,0x45ec,0xa7,0xce,0x85,0x78,0x48,0x14,0x85,0x23>
222 {
223 public:
225  virtual Size get_size() const = 0;
226 
228  virtual Size get_index( const char* name) const = 0;
229 
231  virtual const char* get_name( Size index) const = 0;
232 
234  virtual const IExpression* get_expression( Size index) const = 0;
235 
237  template <class T>
238  const T* get_expression( Size index) const
239  {
240  const IExpression* ptr_expression = get_expression( index);
241  if( !ptr_expression)
242  return 0;
243  const T* ptr_T = static_cast<const T*>( ptr_expression->get_interface( typename T::IID()));
244  ptr_expression->release();
245  return ptr_T;
246  }
247 
249  virtual const IExpression* get_expression( const char* name) const = 0;
250 
252  template <class T>
253  const T* get_expression( const char* name) const
254  {
255  const IExpression* ptr_expression = get_expression( name);
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 
268  virtual Sint32 set_expression( Size index, const IExpression* expression) = 0;
269 
275  virtual Sint32 set_expression( const char* name, const IExpression* expression) = 0;
276 
282  virtual Sint32 add_expression( const char* name, const IExpression* expression) = 0;
283 };
284 
288  mi::base::Interface_declare<0xa453318b,0xe056,0x4521,0x9f,0x3c,0x9d,0x5c,0x3,0x23,0x5f,0xb7>
289 {
290 public:
291 
297  {
299  AS_ANNOTATION_FIRST = 0x0100,
300 
302  = AS_ANNOTATION_FIRST,
309 
333 
334  AS_ANNOTATION_LAST = AS_ORIGIN_ANNOTATION,
335  AS_FORCE_32_BIT = 0xffffffffU // Undocumented, for alignment only.
336  };
337 
339  virtual const char* get_name() const = 0;
340 
342  virtual Semantics get_semantic() const = 0;
343 
345  virtual Size get_parameter_count() const = 0;
346 
352  virtual const char* get_parameter_name(Size index) const = 0;
353 
359  virtual Size get_parameter_index(const char* name) const = 0;
360 
362  virtual const IType_list* get_parameter_types() const = 0;
363 
365  virtual const IExpression_list* get_defaults() const = 0;
366 
368  virtual bool is_exported() const = 0;
369 
372  virtual const IAnnotation_block* get_annotations() const = 0;
373 
380  virtual const IAnnotation* create_annotation(const IExpression_list* arguments) const = 0;
381 };
382 
384 
390 class IAnnotation : public
391  mi::base::Interface_declare<0xa9c652e7,0x952e,0x4887,0x93,0xb4,0x55,0xc8,0x66,0xd0,0x1a,0x1f>
392 {
393 public:
395  virtual const char* get_name() const = 0;
396 
398  virtual void set_name( const char* name) = 0;
399 
403  virtual const IExpression_list* get_arguments() const = 0;
404 
406  virtual const IAnnotation_definition* get_definition() const = 0;
407 };
408 
413 class IAnnotation_block : public
414  mi::base::Interface_declare<0x57b0ae97,0x0815,0x41e8,0x89,0xe7,0x16,0xa1,0x23,0x86,0x80,0x6e>
415 {
416 public:
418  virtual Size get_size() const = 0;
419 
421  virtual const IAnnotation* get_annotation( Size index) const = 0;
422 
428  virtual Sint32 set_annotation( Size index, const IAnnotation* annotation) = 0;
429 
434  virtual Sint32 add_annotation( IAnnotation* annotation) = 0;
435 };
436 
441 class IAnnotation_list : public
442  mi::base::Interface_declare<0x6c4663c2,0x112f,0x4eeb,0x81,0x60,0x41,0xa5,0xa6,0xfb,0x74,0x3c>
443 {
444 public:
446  virtual Size get_size() const = 0;
447 
449  virtual Size get_index( const char* name) const = 0;
450 
452  virtual const char* get_name( Size index) const = 0;
453 
455  virtual const IAnnotation_block* get_annotation_block( Size index) const = 0;
456 
458  virtual const IAnnotation_block* get_annotation_block( const char* name) const = 0;
459 
465  virtual Sint32 set_annotation_block( Size index, const IAnnotation_block* block) = 0;
466 
472  virtual Sint32 set_annotation_block( const char* name, const IAnnotation_block* block) = 0;
473 
479  virtual Sint32 add_annotation_block( const char* name, const IAnnotation_block* block) = 0;
480 };
481 
486 class IExpression_factory : public
487  mi::base::Interface_declare<0x9fd3b2d4,0xb5b8,0x4ccd,0x9b,0x5f,0x7b,0xd9,0x9d,0xeb,0x62,0x64>
488 {
489 public:
491  virtual IValue_factory* get_value_factory() const = 0;
492 
497  virtual IExpression_constant* create_constant( IValue* value) const = 0;
498 
503  virtual IExpression_call* create_call( const char* name) const = 0;
504 
510  virtual IExpression_parameter* create_parameter( const IType* type, Size index) const = 0;
511 
513  virtual IExpression_list* create_expression_list() const = 0;
514 
519  const char* name, const IExpression_list* arguments) const = 0;
520 
522  virtual IAnnotation_block* create_annotation_block() const = 0;
523 
525  virtual IAnnotation_list* create_annotation_list() const = 0;
526 
532  virtual IExpression* clone( const IExpression* expr) const = 0;
533 
539  template <class T>
540  T* clone( const T* expr) const
541  {
542  IExpression* ptr_expr = clone( static_cast<const IExpression*>( expr));
543  if( !ptr_expr)
544  return 0;
545  T* ptr_T = static_cast<T*>( ptr_expr->get_interface( typename T::IID()));
546  ptr_expr->release();
547  return ptr_T;
548  }
549 
554  virtual IExpression_list* clone( const IExpression_list* expression_list) const = 0;
555 
575  virtual Sint32 compare( const IExpression* lhs, const IExpression* rhs) const = 0;
576 
592  virtual Sint32 compare( const IExpression_list* lhs, const IExpression_list* rhs) const = 0;
593 
602  virtual const IString* dump(
603  const IExpression* expr, const char* name, Size depth = 0) const = 0;
604 
614  virtual const IString* dump(
615  const IExpression_list* list, const char* name, Size depth = 0) const = 0;
616 
626  virtual const IString* dump(
627  const IAnnotation* annotation, const char* name, Size depth = 0) const = 0;
628 
638  virtual const IString* dump( const IAnnotation_block* block, const char* name, Size depth = 0)
639  const = 0;
640 
650  virtual const IString* dump( const IAnnotation_list* list, const char* name, Size depth = 0)
651  const = 0;
652 
678  virtual IExpression* create_cast(
679  IExpression* src_expr,
680  const IType* target_type,
681  const char* cast_db_name,
682  bool force_cast,
683  Sint32 *errors = 0) const = 0;
684 };
685  // end group mi_neuray_mdl_types
687 
688 } // namespace neuraylib
689 
690 } // namespace mi
691 
692 #endif // MI_NEURAYLIB_IEXPRESSION_H