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 2019 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 IExpression_list;
19 
24 class IExpression : public
28  mi::base::Interface_declare<0x0f4a7542,0x9b27,0x4924,0xbd,0x8d,0x82,0xe3,0xa9,0xa7,0xa9,0xd6>
29 {
30 public:
32  enum Kind {
43  // Undocumented, for alignment only.
44  EK_FORCE_32_BIT = 0xffffffffU
45  };
46 
48  virtual Kind get_kind() const = 0;
49 
51  virtual const IType* get_type() const = 0;
52 
54  template <class T>
55  const T* get_type() const
56  {
57  const IType* ptr_type = get_type();
58  if( !ptr_type)
59  return 0;
60  const T* ptr_T = static_cast<const T*>( ptr_type->get_interface( typename T::IID()));
61  ptr_type->release();
62  return ptr_T;
63  }
64 };
65 
66 mi_static_assert( sizeof( IExpression::Kind) == sizeof( Uint32));
67 
73 class IExpression_constant : public
74  mi::base::Interface_declare<0x9da8d465,0x4058,0x46cb,0x83,0x6e,0x0e,0x38,0xa6,0x7f,0xcd,0xef,
75  neuraylib::IExpression>
76 {
77 public:
79  static const Kind s_kind = EK_CONSTANT;
80 
82  virtual const IValue* get_value() const = 0;
83 
85  template <class T>
86  const T* get_value() const
87  {
88  const IValue* ptr_value = get_value();
89  if( !ptr_value)
90  return 0;
91  const T* ptr_T = static_cast<const T*>( ptr_value->get_interface( typename T::IID()));
92  ptr_value->release();
93  return ptr_T;
94  }
95 
97  virtual IValue* get_value() = 0;
98 
100  template <class T>
102  {
103  IValue* ptr_value = get_value();
104  if( !ptr_value)
105  return 0;
106  T* ptr_T = static_cast<T*>( ptr_value->get_interface( typename T::IID()));
107  ptr_value->release();
108  return ptr_T;
109  }
110 
117  virtual Sint32 set_value( IValue* value) = 0;
118 };
119 
128 class IExpression_call : public
129  mi::base::Interface_declare<0xcf625aec,0x8eb8,0x4743,0x9f,0xf6,0x76,0x82,0x2c,0x02,0x54,0xa3,
130  neuraylib::IExpression>
131 {
132 public:
134  static const Kind s_kind = EK_CALL;
135 
137  virtual const char* get_call() const = 0;
138 
151  virtual Sint32 set_call( const char* name) = 0;
152 };
153 
157 class IExpression_parameter : public
158  mi::base::Interface_declare<0x206c4319,0x0b53,0x45a7,0x86,0x07,0x29,0x98,0xb3,0x44,0x7f,0xaa,
159  neuraylib::IExpression>
160 {
161 public:
163  static const Kind s_kind = EK_PARAMETER;
164 
166  virtual Size get_index() const = 0;
167 
169  virtual void set_index( Size index) = 0;
170 };
171 
180  mi::base::Interface_declare<0x9253c9d6,0xe162,0x4234,0xab,0x91,0x54,0xc1,0xe4,0x87,0x39,0x66,
181  neuraylib::IExpression>
182 {
183 public:
185  static const Kind s_kind = EK_DIRECT_CALL;
186 
188  virtual const char* get_definition() const = 0;
189 
191  virtual const IExpression_list* get_arguments() const = 0;
192 };
193 
197 class IExpression_temporary : public
198  mi::base::Interface_declare<0xd91f484b,0xdbf8,0x4585,0x9d,0xab,0xba,0xd9,0x91,0x7f,0xe1,0x4c,
199  neuraylib::IExpression>
200 {
201 public:
203  static const Kind s_kind = EK_TEMPORARY;
204 
206  virtual Size get_index() const = 0;
207 
209  virtual void set_index( Size index) = 0;
210 };
211 
216 class IExpression_list : public
217  mi::base::Interface_declare<0x98ce8e89,0x9f23,0x45ec,0xa7,0xce,0x85,0x78,0x48,0x14,0x85,0x23>
218 {
219 public:
221  virtual Size get_size() const = 0;
222 
224  virtual Size get_index( const char* name) const = 0;
225 
227  virtual const char* get_name( Size index) const = 0;
228 
230  virtual const IExpression* get_expression( Size index) const = 0;
231 
233  template <class T>
234  const T* get_expression( Size index) const
235  {
236  const IExpression* ptr_expression = get_expression( index);
237  if( !ptr_expression)
238  return 0;
239  const T* ptr_T = static_cast<const T*>( ptr_expression->get_interface( typename T::IID()));
240  ptr_expression->release();
241  return ptr_T;
242  }
243 
245  virtual const IExpression* get_expression( const char* name) const = 0;
246 
248  template <class T>
249  const T* get_expression( const char* name) const
250  {
251  const IExpression* ptr_expression = get_expression( name);
252  if( !ptr_expression)
253  return 0;
254  const T* ptr_T = static_cast<const T*>( ptr_expression->get_interface( typename T::IID()));
255  ptr_expression->release();
256  return ptr_T;
257  }
258 
264  virtual Sint32 set_expression( Size index, const IExpression* expression) = 0;
265 
271  virtual Sint32 set_expression( const char* name, const IExpression* expression) = 0;
272 
278  virtual Sint32 add_expression( const char* name, const IExpression* expression) = 0;
279 };
280 
285 class IAnnotation : public
286  mi::base::Interface_declare<0xa9c652e7,0x952e,0x4887,0x93,0xb4,0x55,0xc8,0x66,0xd0,0x1a,0x1f>
287 {
288 public:
290  virtual const char* get_name() const = 0;
291 
293  virtual void set_name( const char* name) = 0;
294 
298  virtual const IExpression_list* get_arguments() const = 0;
299 };
300 
305 class IAnnotation_block : public
306  mi::base::Interface_declare<0x57b0ae97,0x0815,0x41e8,0x89,0xe7,0x16,0xa1,0x23,0x86,0x80,0x6e>
307 {
308 public:
310  virtual Size get_size() const = 0;
311 
313  virtual const IAnnotation* get_annotation( Size index) const = 0;
314 
320  virtual Sint32 set_annotation( Size index, const IAnnotation* annotation) = 0;
321 
326  virtual Sint32 add_annotation( IAnnotation* annotation) = 0;
327 };
328 
333 class IAnnotation_list : public
334  mi::base::Interface_declare<0x6c4663c2,0x112f,0x4eeb,0x81,0x60,0x41,0xa5,0xa6,0xfb,0x74,0x3c>
335 {
336 public:
338  virtual Size get_size() const = 0;
339 
341  virtual Size get_index( const char* name) const = 0;
342 
344  virtual const char* get_name( Size index) const = 0;
345 
347  virtual const IAnnotation_block* get_annotation_block( Size index) const = 0;
348 
350  virtual const IAnnotation_block* get_annotation_block( const char* name) const = 0;
351 
357  virtual Sint32 set_annotation_block( Size index, const IAnnotation_block* block) = 0;
358 
364  virtual Sint32 set_annotation_block( const char* name, const IAnnotation_block* block) = 0;
365 
371  virtual Sint32 add_annotation_block( const char* name, const IAnnotation_block* block) = 0;
372 };
373 
378 class IExpression_factory : public
379  mi::base::Interface_declare<0x9fd3b2d4,0xb5b8,0x4ccd,0x9b,0x5f,0x7b,0xd9,0x9d,0xeb,0x62,0x64>
380 {
381 public:
383  virtual IValue_factory* get_value_factory() const = 0;
384 
389  virtual IExpression_constant* create_constant( IValue* value) const = 0;
390 
395  virtual IExpression_call* create_call( const char* name) const = 0;
396 
402  virtual IExpression_parameter* create_parameter( const IType* type, Size index) const = 0;
403 
405  virtual IExpression_list* create_expression_list() const = 0;
406 
411  const char* name, const IExpression_list* arguments) const = 0;
412 
414  virtual IAnnotation_block* create_annotation_block() const = 0;
415 
417  virtual IAnnotation_list* create_annotation_list() const = 0;
418 
424  virtual IExpression* clone( const IExpression* expr) const = 0;
425 
431  template <class T>
432  T* clone( const T* expr) const
433  {
434  IExpression* ptr_expr = clone( static_cast<const IExpression*>( expr));
435  if( !ptr_expr)
436  return 0;
437  T* ptr_T = static_cast<T*>( ptr_expr->get_interface( typename T::IID()));
438  ptr_expr->release();
439  return ptr_T;
440  }
441 
446  virtual IExpression_list* clone( const IExpression_list* expression_list) const = 0;
447 
467  virtual Sint32 compare( const IExpression* lhs, const IExpression* rhs) const = 0;
468 
484  virtual Sint32 compare( const IExpression_list* lhs, const IExpression_list* rhs) const = 0;
485 
494  virtual const IString* dump(
495  const IExpression* expr, const char* name, Size depth = 0) const = 0;
496 
506  virtual const IString* dump(
507  const IExpression_list* list, const char* name, Size depth = 0) const = 0;
508 
518  virtual const IString* dump(
519  const IAnnotation* annotation, const char* name, Size depth = 0) const = 0;
520 
530  virtual const IString* dump( const IAnnotation_block* block, const char* name, Size depth = 0)
531  const = 0;
532 
542  virtual const IString* dump( const IAnnotation_list* list, const char* name, Size depth = 0)
543  const = 0;
544 };
545  // end group mi_neuray_mdl_types
547 
548 } // namespace neuraylib
549 
550 } // namespace mi
551 
552 #endif // MI_NEURAYLIB_IEXPRESSION_H