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 2018 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 
149  virtual Sint32 set_call( const char* name) = 0;
150 };
151 
155 class IExpression_parameter : public
156  mi::base::Interface_declare<0x206c4319,0x0b53,0x45a7,0x86,0x07,0x29,0x98,0xb3,0x44,0x7f,0xaa,
157  neuraylib::IExpression>
158 {
159 public:
161  static const Kind s_kind = EK_PARAMETER;
162 
164  virtual Size get_index() const = 0;
165 
167  virtual void set_index( Size index) = 0;
168 };
169 
178  mi::base::Interface_declare<0x9253c9d6,0xe162,0x4234,0xab,0x91,0x54,0xc1,0xe4,0x87,0x39,0x66,
179  neuraylib::IExpression>
180 {
181 public:
183  static const Kind s_kind = EK_DIRECT_CALL;
184 
186  virtual const char* get_definition() const = 0;
187 
189  virtual const IExpression_list* get_arguments() const = 0;
190 };
191 
195 class IExpression_temporary : public
196  mi::base::Interface_declare<0xd91f484b,0xdbf8,0x4585,0x9d,0xab,0xba,0xd9,0x91,0x7f,0xe1,0x4c,
197  neuraylib::IExpression>
198 {
199 public:
201  static const Kind s_kind = EK_TEMPORARY;
202 
204  virtual Size get_index() const = 0;
205 
207  virtual void set_index( Size index) = 0;
208 };
209 
214 class IExpression_list : public
215  mi::base::Interface_declare<0x98ce8e89,0x9f23,0x45ec,0xa7,0xce,0x85,0x78,0x48,0x14,0x85,0x23>
216 {
217 public:
219  virtual Size get_size() const = 0;
220 
222  virtual Size get_index( const char* name) const = 0;
223 
225  virtual const char* get_name( Size index) const = 0;
226 
228  virtual const IExpression* get_expression( Size index) const = 0;
229 
231  template <class T>
232  const T* get_expression( Size index) const
233  {
234  const IExpression* ptr_expression = get_expression( index);
235  if( !ptr_expression)
236  return 0;
237  const T* ptr_T = static_cast<const T*>( ptr_expression->get_interface( typename T::IID()));
238  ptr_expression->release();
239  return ptr_T;
240  }
241 
243  virtual const IExpression* get_expression( const char* name) const = 0;
244 
246  template <class T>
247  const T* get_expression( const char* name) const
248  {
249  const IExpression* ptr_expression = get_expression( name);
250  if( !ptr_expression)
251  return 0;
252  const T* ptr_T = static_cast<const T*>( ptr_expression->get_interface( typename T::IID()));
253  ptr_expression->release();
254  return ptr_T;
255  }
256 
262  virtual Sint32 set_expression( Size index, const IExpression* expression) = 0;
263 
269  virtual Sint32 set_expression( const char* name, const IExpression* expression) = 0;
270 
276  virtual Sint32 add_expression( const char* name, const IExpression* expression) = 0;
277 };
278 
283 class IAnnotation : public
284  mi::base::Interface_declare<0xa9c652e7,0x952e,0x4887,0x93,0xb4,0x55,0xc8,0x66,0xd0,0x1a,0x1f>
285 {
286 public:
288  virtual const char* get_name() const = 0;
289 
291  virtual void set_name( const char* name) = 0;
292 
296  virtual const IExpression_list* get_arguments() const = 0;
297 };
298 
303 class IAnnotation_block : public
304  mi::base::Interface_declare<0x57b0ae97,0x0815,0x41e8,0x89,0xe7,0x16,0xa1,0x23,0x86,0x80,0x6e>
305 {
306 public:
308  virtual Size get_size() const = 0;
309 
311  virtual const IAnnotation* get_annotation( Size index) const = 0;
312 
318  virtual Sint32 set_annotation( Size index, const IAnnotation* annotation) = 0;
319 
324  virtual Sint32 add_annotation( IAnnotation* annotation) = 0;
325 };
326 
331 class IAnnotation_list : public
332  mi::base::Interface_declare<0x6c4663c2,0x112f,0x4eeb,0x81,0x60,0x41,0xa5,0xa6,0xfb,0x74,0x3c>
333 {
334 public:
336  virtual Size get_size() const = 0;
337 
339  virtual Size get_index( const char* name) const = 0;
340 
342  virtual const char* get_name( Size index) const = 0;
343 
345  virtual const IAnnotation_block* get_annotation_block( Size index) const = 0;
346 
348  virtual const IAnnotation_block* get_annotation_block( const char* name) const = 0;
349 
355  virtual Sint32 set_annotation_block( Size index, const IAnnotation_block* block) = 0;
356 
362  virtual Sint32 set_annotation_block( const char* name, const IAnnotation_block* block) = 0;
363 
369  virtual Sint32 add_annotation_block( const char* name, const IAnnotation_block* block) = 0;
370 };
371 
376 class IExpression_factory : public
377  mi::base::Interface_declare<0x9fd3b2d4,0xb5b8,0x4ccd,0x9b,0x5f,0x7b,0xd9,0x9d,0xeb,0x62,0x64>
378 {
379 public:
381  virtual IValue_factory* get_value_factory() const = 0;
382 
387  virtual IExpression_constant* create_constant( IValue* value) const = 0;
388 
393  virtual IExpression_call* create_call( const char* name) const = 0;
394 
400  virtual IExpression_parameter* create_parameter( const IType* type, Size index) const = 0;
401 
403  virtual IExpression_list* create_expression_list() const = 0;
404 
409  const char* name, const IExpression_list* arguments) const = 0;
410 
412  virtual IAnnotation_block* create_annotation_block() const = 0;
413 
415  virtual IAnnotation_list* create_annotation_list() const = 0;
416 
422  virtual IExpression* clone( const IExpression* expr) const = 0;
423 
429  template <class T>
430  T* clone( const T* expr) const
431  {
432  IExpression* ptr_expr = clone( static_cast<const IExpression*>( expr));
433  if( !ptr_expr)
434  return 0;
435  T* ptr_T = static_cast<T*>( ptr_expr->get_interface( typename T::IID()));
436  ptr_expr->release();
437  return ptr_T;
438  }
439 
444  virtual IExpression_list* clone( const IExpression_list* expression_list) const = 0;
445 
465  virtual Sint32 compare( const IExpression* lhs, const IExpression* rhs) const = 0;
466 
482  virtual Sint32 compare( const IExpression_list* lhs, const IExpression_list* rhs) const = 0;
483 
492  virtual const IString* dump(
493  const IExpression* expr, const char* name, Size depth = 0) const = 0;
494 
504  virtual const IString* dump(
505  const IExpression_list* list, const char* name, Size depth = 0) const = 0;
506 
516  virtual const IString* dump(
517  const IAnnotation* annotation, const char* name, Size depth = 0) const = 0;
518 
528  virtual const IString* dump( const IAnnotation_block* block, const char* name, Size depth = 0)
529  const = 0;
530 
540  virtual const IString* dump( const IAnnotation_list* list, const char* name, Size depth = 0)
541  const = 0;
542 };
543  // end group mi_neuray_mdl_types
545 
546 } // namespace neuraylib
547 
548 } // namespace mi
549 
550 #endif // MI_NEURAYLIB_IEXPRESSION_H