MDL SDK API nvidia_logo_transpbg.gif Up
ivalue.h
Go to the documentation of this file.
1/***************************************************************************************************
2 * Copyright 2025 NVIDIA Corporation. All rights reserved.
3 **************************************************************************************************/
6
7#ifndef MI_NEURAYLIB_IVALUE_H
8#define MI_NEURAYLIB_IVALUE_H
9
10#include <mi/base/handle.h>
11#include <mi/math/color.h>
12#include <mi/math/matrix.h>
13#include <mi/math/spectrum.h>
14#include <mi/math/vector.h>
15#include <mi/neuraylib/itype.h>
16#include <mi/neuraylib/version.h> // for MI_NEURAYLIB_DEPRECATED_ENUM_VALUE
17
18namespace mi {
19
20namespace neuraylib {
21
26class IAnnotation;
27class IAnnotation_block;
28
32class IValue : public
33 mi::base::Interface_declare<0xbf837f4a,0x9034,0x4f32,0xaf,0x5c,0x75,0xb3,0x67,0x64,0x53,0x23>
34{
35public:
37 enum Kind : Uint32 {
68 MI_NEURAYLIB_DEPRECATED_ENUM_VALUE(VK_FORCE_32_BIT, 0xffffffffU)
69 };
70
72 virtual Kind get_kind() const = 0;
73
75 virtual const IType* get_type() const = 0;
76
78 template <class T>
79 const T* get_type() const
80 {
81 const IType* ptr_type = get_type();
82 if( !ptr_type)
83 return 0;
84 const T* ptr_T = static_cast<const T*>( ptr_type->get_interface( typename T::IID()));
85 ptr_type->release();
86 return ptr_T;
87 }
88};
89
91class IValue_atomic : public
92 mi::base::Interface_declare<0xf2413c80,0x8e71,0x4974,0xaa,0xf2,0x60,0xd5,0xe2,0x94,0x9d,0x3e,
93 neuraylib::IValue>
94{
95public:
97 virtual const IType_atomic* get_type() const = 0;
98};
99
101class IValue_bool : public
102 mi::base::Interface_declare<0xaf253a14,0x1f04,0x4b67,0xba,0x70,0x7b,0x01,0x05,0xfb,0xc8,0xf5,
103 neuraylib::IValue_atomic>
104{
105public:
107 static const Kind s_kind = VK_BOOL;
108
110 virtual const IType_bool* get_type() const = 0;
111
113 virtual bool get_value() const = 0;
114
116 virtual void set_value( bool value) = 0;
117};
118
120class IValue_int : public
121 mi::base::Interface_declare<0x91e6f145,0x280d,0x4d68,0x95,0x57,0xe1,0xd0,0x9c,0xd2,0x5c,0x74,
122 neuraylib::IValue_atomic>
123{
124public:
126 static const Kind s_kind = VK_INT;
127
129 virtual const IType_int* get_type() const = 0;
130
132 virtual Sint32 get_value() const = 0;
133
135 virtual void set_value( Sint32 value) = 0;
136};
137
139class IValue_enum : public
140 mi::base::Interface_declare<0xdc876204,0x8a97,0x40e9,0xb9,0xb6,0xca,0xdc,0xdd,0x60,0x1f,0xbf,
141 neuraylib::IValue_atomic>
142{
143public:
145 static const Kind s_kind = VK_ENUM;
146
148 virtual const IType_enum* get_type() const = 0;
149
151 virtual Sint32 get_value() const = 0;
152
154 virtual Size get_index() const = 0;
155
161 virtual Sint32 set_value( Sint32 value) = 0;
162
166 virtual Sint32 set_index( Size index) = 0;
167
169 virtual const char* get_name() const = 0;
170
174 virtual Sint32 set_name( const char* name) = 0;
175};
176
178class IValue_float : public
179 mi::base::Interface_declare<0x21f07151,0x74b5,0x4296,0x90,0x29,0xc7,0xde,0x49,0x38,0x2a,0xbc,
180 neuraylib::IValue_atomic>
181{
182public:
184 static const Kind s_kind = VK_FLOAT;
185
187 virtual const IType_float* get_type() const = 0;
188
190 virtual Float32 get_value() const = 0;
191
193 virtual void set_value( Float32 value) = 0;
194};
195
197class IValue_double : public
198 mi::base::Interface_declare<0xbdc84417,0x3e83,0x4bab,0x90,0xb1,0x9f,0x57,0xed,0x7b,0x15,0x03,
199 neuraylib::IValue_atomic>
200{
201public:
203 static const Kind s_kind = VK_DOUBLE;
204
206 virtual const IType_double* get_type() const = 0;
207
209 virtual Float64 get_value() const = 0;
210
212 virtual void set_value( Float64 value) = 0;
213};
214
216class IValue_string : public
217 mi::base::Interface_declare<0x64b28506,0x8675,0x4724,0xa1,0x0d,0xc6,0xf2,0x35,0x46,0x26,0x39,
218 neuraylib::IValue_atomic>
219{
220public:
222 static const Kind s_kind = VK_STRING;
223
225 virtual const IType_string* get_type() const = 0;
226
228 virtual const char* get_value() const = 0;
229
231 virtual void set_value( const char* value) = 0;
232};
233
237 mi::base::Interface_declare<0x1fe80d3d,0xe79e,0x4bdb,0xb6,0x30,0xe3,0x36,0x31,0xa4,0x1e,0x39,
238 neuraylib::IValue_string>
239{
240public:
243 virtual const char* get_original_value() const = 0;
244};
245
247class IValue_compound : public
248 mi::base::Interface_declare<0xdabc8fe3,0x5c70,0x4ef0,0xa2,0xf7,0x34,0x30,0xb5,0x67,0xdc,0x75,
249 neuraylib::IValue>
250{
251public:
253 virtual const IType_compound* get_type() const = 0;
254
256 virtual Size get_size() const = 0;
257
259 virtual const IValue* get_value( Size index) const = 0;
260
262 template <class T>
263 const T* get_value( Size index) const
264 {
265 const IValue* ptr_value = get_value( index);
266 if( !ptr_value)
267 return 0;
268 const T* ptr_T = static_cast<const T*>( ptr_value->get_interface( typename T::IID()));
269 ptr_value->release();
270 return ptr_T;
271 }
272
274 virtual IValue* get_value( Size index) = 0;
275
277 template <class T>
278 T* get_value( Size index)
279 {
280 IValue* ptr_value = get_value( index);
281 if( !ptr_value)
282 return 0;
283 T* ptr_T = static_cast<T*>( ptr_value->get_interface( typename T::IID()));
284 ptr_value->release();
285 return ptr_T;
286 }
287
297 virtual Sint32 set_value( Size index, IValue* value) = 0;
298};
299
304class IValue_vector : public
305 mi::base::Interface_declare<0xf5d09fc3,0xd783,0x4571,0x8d,0x59,0x41,0xb1,0xff,0xd3,0x91,0x49,
306 neuraylib::IValue_compound>
307{
308public:
310 static const Kind s_kind = VK_VECTOR;
311
313 virtual const IType_vector* get_type() const = 0;
314
316 virtual const IValue_atomic* get_value( Size index) const = 0;
317
319 template <class T>
320 const T* get_value( Size index) const
321 {
322 const IValue_atomic* ptr_value = get_value( index);
323 if( !ptr_value)
324 return 0;
325 const T* ptr_T = static_cast<const T*>( ptr_value->get_interface( typename T::IID()));
326 ptr_value->release();
327 return ptr_T;
328 }
329
331 virtual IValue_atomic* get_value( Size index) = 0;
332
334 template <class T>
335 T* get_value( Size index)
336 {
337 IValue_atomic* ptr_value = get_value( index);
338 if( !ptr_value)
339 return 0;
340 T* ptr_T = static_cast<T*>( ptr_value->get_interface( typename T::IID()));
341 ptr_value->release();
342 return ptr_T;
343 }
344};
345
350class IValue_matrix : public
351 mi::base::Interface_declare<0x9ee95da6,0x2cd6,0x4168,0x89,0xea,0x92,0x10,0x57,0xda,0xe6,0xdc,
352 neuraylib::IValue_compound>
353{
354public:
356 static const Kind s_kind = VK_MATRIX;
357
359 virtual const IType_matrix* get_type() const = 0;
360
362 virtual const IValue_vector* get_value( Size index) const = 0;
363
365 virtual IValue_vector* get_value( Size index) = 0;
366};
367
369class IValue_color : public
370 mi::base::Interface_declare<0x3bb9bf46,0x1cbb,0x4460,0xbe,0x27,0x10,0xf5,0x71,0x61,0x96,0xa2,
371 neuraylib::IValue_compound>
372{
373public:
375 static const Kind s_kind = VK_COLOR;
376
378 virtual const IType_color* get_type() const = 0;
379
381 virtual const IValue_float* get_value( Size index) const = 0;
382
384 virtual IValue_float* get_value( Size index) = 0;
385
392 virtual Sint32 set_value( Size index, IValue_float* value) = 0;
393
395};
396
398class IValue_array : public
399 mi::base::Interface_declare<0xa17c5f57,0xa647,0x41c4,0x86,0x2f,0x4c,0x0d,0xe1,0x30,0x08,0xfc,
400 neuraylib::IValue_compound>
401{
402public:
404 static const Kind s_kind = VK_ARRAY;
405
407 virtual const IType_array* get_type() const = 0;
408
415 virtual Sint32 set_size( Size size) = 0;
416};
417
419class IValue_struct : public
420 mi::base::Interface_declare<0xcbe089ce,0x4aea,0x474d,0x94,0x5f,0x52,0x13,0xef,0x01,0xce,0x81,
421 neuraylib::IValue_compound>
422{
423public:
425 static const Kind s_kind = VK_STRUCT;
426
428 virtual const IType_struct* get_type() const = 0;
429
434 virtual const IValue* get_field( const char* name) const = 0;
435
440 template <class T>
441 const T* get_field( const char* name) const
442 {
443 const IValue* ptr_value = get_field( name);
444 if( !ptr_value)
445 return 0;
446 T* ptr_T = static_cast<T*>( ptr_value->get_interface( typename T::IID()));
447 ptr_value->release();
448 return ptr_T;
449 }
450
455 virtual IValue* get_field( const char* name) = 0;
456
461 template <class T>
462 T* get_field( const char* name)
463 {
464 IValue* ptr_value = get_field( name);
465 if( !ptr_value)
466 return 0;
467 T* ptr_T = static_cast<T*>( ptr_value->get_interface( typename T::IID()));
468 ptr_value->release();
469 return ptr_T;
470 }
471
481 virtual Sint32 set_field( const char* name, IValue* value) = 0;
482};
483
485class IValue_resource : public
486 mi::base::Interface_declare<0x479bb10c,0xd444,0x426c,0x83,0xab,0x26,0xdf,0xf6,0x1d,0x6f,0xd7,
487 neuraylib::IValue>
488{
489public:
491 virtual const IType_resource* get_type() const = 0;
492
496 virtual const char* get_value() const = 0;
497
508 virtual Sint32 set_value( const char* value) = 0;
509
514 virtual const char* get_file_path() const = 0;
515
516 virtual const char* get_owner_module() const = 0;
517};
518
520class IValue_texture : public
521 mi::base::Interface_declare<0xf2a03651,0x8883,0x4ba4,0xb9,0xa9,0xe6,0x87,0x34,0x3a,0xb3,0xb8,
522 neuraylib::IValue_resource>
523{
524public:
526 static const Kind s_kind = VK_TEXTURE;
527
529 virtual const IType_texture* get_type() const = 0;
530
535 virtual Float32 get_gamma() const = 0;
536
538 virtual const char* get_selector() const = 0;
539};
540
543 mi::base::Interface_declare<0xd7c9ffbd,0xb5e4,0x4bf4,0x90,0xd0,0xe9,0x75,0x4d,0x6d,0x49,0x07,
544 neuraylib::IValue_resource>
545{
546public:
549
551 virtual const IType_light_profile* get_type() const = 0;
552};
553
556 mi::base::Interface_declare<0x31a55244,0x415c,0x4b4d,0xa7,0x86,0x2f,0x21,0x9c,0xb8,0xb9,0xff,
557 neuraylib::IValue_resource>
558{
559public:
562
564 virtual const IType_bsdf_measurement* get_type() const = 0;
565};
566
568class IValue_invalid_df : public
569 mi::base::Interface_declare<0x1588b6fa,0xa143,0x4bac,0xa0,0x32,0x06,0xbd,0x9e,0x7f,0xb6,0xe5,
570 neuraylib::IValue>
571{
572public:
574 static const Kind s_kind = VK_INVALID_DF;
575
577 virtual const IType_reference* get_type() const = 0;
578};
579
583class IValue_list : public
584 mi::base::Interface_declare<0x8027a5e5,0x4e25,0x410c,0xbb,0xce,0x84,0xb4,0x88,0x8b,0x03,0x46>
585{
586public:
588 virtual Size get_size() const = 0;
589
591 virtual Size get_index( const char* name) const = 0;
592
594 virtual const char* get_name( Size index) const = 0;
595
597 virtual const IValue* get_value( Size index) const = 0;
598
600 template <class T>
601 const T* get_value( Size index) const
602 {
603 const IValue* ptr_value = get_value( index);
604 if( !ptr_value)
605 return 0;
606 const T* ptr_T = static_cast<const T*>( ptr_value->get_interface( typename T::IID()));
607 ptr_value->release();
608 return ptr_T;
609 }
610
612 virtual const IValue* get_value( const char* name) const = 0;
613
615 template <class T>
616 const T* get_value( const char* name) const
617 {
618 const IValue* ptr_value = get_value( name);
619 if( !ptr_value)
620 return 0;
621 const T* ptr_T = static_cast<const T*>( ptr_value->get_interface( typename T::IID()));
622 ptr_value->release();
623 return ptr_T;
624 }
625
632 virtual Sint32 set_value( Size index, const IValue* value) = 0;
633
640 virtual Sint32 set_value( const char* name, const IValue* value) = 0;
641
648 virtual Sint32 add_value( const char* name, const IValue* value) = 0;
649};
650
656class IValue_factory : public
657 mi::base::Interface_declare<0x82595c0d,0x3687,0x4b45,0xa3,0x38,0x42,0x20,0x02,0xea,0x3f,0x9b>
658{
659public:
661
662
664 virtual IType_factory* get_type_factory() const = 0;
665
667
669
671 virtual IValue_bool* create_bool( bool value = false) const = 0;
672
674 virtual IValue_int* create_int( Sint32 value = 0) const = 0;
675
677 virtual IValue_enum* create_enum( const IType_enum* type, Size index = 0) const = 0;
678
680 virtual IValue_float* create_float( Float32 value = 0.0f) const = 0;
681
683 virtual IValue_double* create_double( Float64 value = 0.0) const = 0;
684
688 virtual IValue_string* create_string( const char* value = "") const = 0;
689
691 virtual IValue_vector* create_vector( const IType_vector* type) const = 0;
692
694 virtual IValue_matrix* create_matrix( const IType_matrix* type) const = 0;
695
698 Float32 red = 0.0f,
699 Float32 green = 0.0f,
700 Float32 blue = 0.0f) const = 0;
701
703 virtual IValue_array* create_array( const IType_array* type) const = 0;
704
706 virtual IValue_struct* create_struct( const IType_struct* type) const = 0;
707
709 virtual IValue_texture* create_texture( const IType_texture* type, const char* value) const = 0;
710
712 virtual IValue_light_profile* create_light_profile( const char* value) const = 0;
713
715 virtual IValue_bsdf_measurement* create_bsdf_measurement( const char* value) const = 0;
716
718 virtual IValue_invalid_df* create_invalid_df( const IType_reference* type) const = 0;
719
721 virtual IValue* create( const IType* type) const = 0;
722
724 template <class T>
725 T* create( const IType* type) const
726 {
727 IValue* ptr_value = create( type);
728 if( !ptr_value)
729 return nullptr;
730 T* ptr_T = static_cast<T*>( ptr_value->get_interface( typename T::IID()));
731 ptr_value->release();
732 return ptr_T;
733 }
734
739 virtual IValue* create( const IAnnotation* annotation) const = 0;
740
745 template <class T>
746 T* create( const IAnnotation* annotation) const
747 {
748 IValue* ptr_value = create( annotation);
749 if( !ptr_value)
750 return 0;
751 T* ptr_T = static_cast<T*>( ptr_value->get_interface( typename T::IID()));
752 ptr_value->release();
753 return ptr_T;
754 }
755
764 virtual IValue* create( const IType* type, const IAnnotation_block* annotation_block) const = 0;
765
774 template <class T>
775 T* create( const IType* type, const IAnnotation_block* annotation_block) const
776 {
777 IValue* ptr_value = create( type, annotation_block);
778 if( !ptr_value)
779 return 0;
780 T* ptr_T = static_cast<T*>( ptr_value->get_interface( typename T::IID()));
781 ptr_value->release();
782 return ptr_T;
783 }
784
786 virtual IValue_list* create_value_list() const = 0;
787
789
791
795 virtual IValue* clone( const IValue* value) const = 0;
796
800 template <class T>
801 T* clone( const T* value) const
802 {
803 IValue* ptr_value = clone( static_cast<const IValue*>( value));
804 if( !ptr_value)
805 return 0;
806 T* ptr_T = static_cast<T*>( ptr_value->get_interface( typename T::IID()));
807 ptr_value->release();
808 return ptr_T;
809 }
810
814 virtual IValue_list* clone( const IValue_list* value_list) const = 0;
815
817
819
842 const IValue* lhs, const IValue* rhs, Float64 epsilon = 0.0) const = 0;
843
859 const IValue_list* lhs, const IValue_list* rhs, Float64 epsilon = 0.0) const = 0;
860
862
864
876 virtual const IString* dump( const IValue* value, const char* name, Size depth = 0) const = 0;
877
887 virtual const IString* dump(
888 const IValue_list* list, const char* name, Size depth = 0) const = 0;
889
891};
892
923template<class T>
925{
928 if( value_int) {
929 value_int->set_value( v);
930 return 0;
931 }
932
935 if( value_enum) {
936 if( value_enum->set_value( v) != 0)
937 return -2;
938 return 0;
939 }
940
941 return -1;
942}
943
947inline mi::Sint32 set_value( mi::neuraylib::IValue* value, const bool& v)
948{
951 if( value_bool) {
952 value_bool->set_value( v);
953 return 0;
954 }
955
956 return -1;
957}
958
963{
966 if( value_float) {
967 value_float->set_value( v);
968 return 0;
969 }
970
973 if( value_double) {
974 value_double->set_value( v);
975 return 0;
976 }
977
978 return -1;
979}
980
985{
988 if( value_float) {
989 value_float->set_value( static_cast<mi::Float32>( v));
990 return 0;
991 }
992
995 if( value_double) {
996 value_double->set_value( v);
997 return 0;
998 }
999
1000 return -1;
1001}
1002
1007inline mi::Sint32 set_value( mi::neuraylib::IValue* value, const char* v)
1008{
1011 if( value_enum) {
1012 if( value_enum->set_name( v) != 0)
1013 return -2;
1014 return 0;
1015 }
1016
1019 if( value_string) {
1020 value_string->set_value( v);
1021 return 0;
1022 }
1023
1026 if( value_resource) {
1027 if( value_resource->set_value( v) != 0)
1028 return -2;
1029 return 0;
1030 }
1031
1032 return -1;
1033}
1034
1039template<class T, Size DIM>
1041{
1044 if( value_vector) {
1045 if( value_vector->get_size() != DIM)
1046 return -1;
1047 for( Size i = 0; i < DIM; ++i) {
1048 mi::base::Handle<mi::neuraylib::IValue> component( value_vector->get_value( i));
1049 mi::Sint32 result = set_value( component.get(), v[i]);
1050 if( result != 0)
1051 return result;
1052 }
1053 return 0;
1054 }
1055
1056 return -1;
1057}
1058
1068template<class T, Size ROW, Size COL>
1070{
1073 if( value_matrix) {
1074 if( value_matrix->get_size() != ROW)
1075 return -1;
1076 for( Size i = 0; i < ROW; ++i) {
1077 mi::base::Handle<mi::neuraylib::IValue_vector> column( value_matrix->get_value( i));
1078 if( column->get_size() != COL)
1079 return -1;
1080 for( Size j = 0; j < COL; ++j) {
1081 mi::base::Handle<mi::neuraylib::IValue> element( column->get_value( j));
1082 mi::Sint32 result = set_value( element.get(), v[i][j]);
1083 if( result != 0)
1084 return result;
1085 }
1086 }
1087 return 0;
1088 }
1089
1090 return -1;
1091}
1092
1097{
1100 if( value_color) {
1101 mi::base::Handle<mi::neuraylib::IValue_float> red ( value_color->get_value( 0));
1102 red ->set_value( v.r);
1103 mi::base::Handle<mi::neuraylib::IValue_float> green( value_color->get_value( 1));
1104 green->set_value( v.g);
1105 mi::base::Handle<mi::neuraylib::IValue_float> blue ( value_color->get_value( 2));
1106 blue ->set_value( v.b);
1107 return 0;
1108 }
1109
1110 return -1;
1111}
1112
1118{
1121 if( value_color) {
1122 mi::base::Handle<mi::neuraylib::IValue_float> red ( value_color->get_value( 0));
1123 red ->set_value( v[0]);
1124 mi::base::Handle<mi::neuraylib::IValue_float> green( value_color->get_value( 1));
1125 green->set_value( v[1]);
1126 mi::base::Handle<mi::neuraylib::IValue_float> blue ( value_color->get_value( 2));
1127 blue ->set_value( v[2]);
1128 return 0;
1129 }
1130
1131 return -1;
1132}
1133
1147template<class T>
1149{
1152 if( value_compound) {
1153 mi::base::Handle<mi::neuraylib::IValue> component( value_compound->get_value( index));
1154 if( !component)
1155 return -3;
1156 return set_value( component.get(), v);
1157 }
1158
1159 return -1;
1160}
1161
1175template<class T>
1176mi::Sint32 set_value( mi::neuraylib::IValue* value, const char* name, const T& v)
1177{
1180 if( value_struct) {
1181 mi::base::Handle<mi::neuraylib::IValue> field( value_struct->get_field( name));
1182 if( !field)
1183 return -3;
1184 return set_value( field.get(), v);
1185 }
1186
1187 return -1;
1188}
1189
1203template<class T>
1205{
1208 if( value_array) {
1209 if( value_array->get_size() != n)
1210 return -5;
1211 for( mi::Size i = 0; i < n; ++i) {
1212 mi::base::Handle<mi::neuraylib::IValue> element( value_array->get_value( i));
1213 mi::Sint32 result = set_value( element.get(), v[i]);
1214 if( result != 0)
1215 return result;
1216 }
1217 return 0;
1218 }
1219
1220 return -1;
1221}
1222
1252template<class T>
1254{
1257 if( value_int) {
1258 v = value_int->get_value();
1259 return 0;
1260 }
1261
1264 if( value_enum) {
1265 v = value_enum->get_value();
1266 return 0;
1267 }
1268
1269 return -1;
1270}
1271
1275inline mi::Sint32 get_value( const mi::neuraylib::IValue* value, bool& v)
1276{
1279 if( value_bool) {
1280 v = value_bool->get_value();
1281 return 0;
1282 }
1283
1284 return -1;
1285}
1286
1291{
1294 if( value_float) {
1295 v = value_float->get_value();
1296 return 0;
1297 }
1298
1301 if( value_double) {
1302 v = static_cast<mi::Float32>( value_double->get_value());
1303 return 0;
1304 }
1305
1306 return -1;
1307}
1308
1313{
1316 if( value_float) {
1317 v = value_float->get_value();
1318 return 0;
1319 }
1320
1323 if( value_double) {
1324 v = value_double->get_value();
1325 return 0;
1326 }
1327
1328 return -1;
1329}
1330
1335inline mi::Sint32 get_value( const mi::neuraylib::IValue* value, const char*& v)
1336{
1339 if( value_enum) {
1340 v = value_enum->get_name();
1341 return 0;
1342 }
1343
1346 if( value_string) {
1347 v = value_string->get_value();
1348 return 0;
1349 }
1350
1353 if( value_resource) {
1354 v = value_resource->get_value();
1355 return 0;
1356 }
1357
1358 return -1;
1359}
1360
1365template <class T, Size DIM>
1367{
1370 if( value_vector) {
1371 if( value_vector->get_size() != DIM)
1372 return -1;
1373 for( Size i = 0; i < DIM; ++i) {
1374 mi::base::Handle<const mi::neuraylib::IValue> component( value_vector->get_value( i));
1375 mi::Sint32 result = get_value( component.get(), v[i]);
1376 if( result != 0)
1377 return result;
1378 }
1379 return 0;
1380 }
1381
1382 return -1;
1383}
1384
1394template <class T, Size ROW, Size COL>
1396{
1399 if( value_matrix) {
1400 if( value_matrix->get_size() != ROW)
1401 return -1;
1402 for( Size i = 0; i < ROW; ++i) {
1404 value_matrix->get_value( i));
1405 if( column->get_size() != COL)
1406 return -1;
1407 for( Size j = 0; j < COL; ++j) {
1408 mi::base::Handle<const mi::neuraylib::IValue> element( column->get_value( j));
1409 mi::Sint32 result = get_value( element.get(), v[i][j]);
1410 if( result != 0)
1411 return result;
1412 }
1413 }
1414 return 0;
1415 }
1416
1417 return -1;
1418}
1419
1424{
1427 if( value_color) {
1428 mi::base::Handle<const mi::neuraylib::IValue_float> red ( value_color->get_value( 0));
1429 v.r = red ->get_value();
1430 mi::base::Handle<const mi::neuraylib::IValue_float> green( value_color->get_value( 1));
1431 v.g = green->get_value();
1432 mi::base::Handle<const mi::neuraylib::IValue_float> blue ( value_color->get_value( 2));
1433 v.b = blue ->get_value();
1434 v.a = 1.0f;
1435 return 0;
1436 }
1437
1438 return -1;
1439}
1440
1446{
1449 if( value_color) {
1450 mi::base::Handle<const mi::neuraylib::IValue_float> red ( value_color->get_value( 0));
1451 v[0] = red ->get_value();
1452 mi::base::Handle<const mi::neuraylib::IValue_float> green( value_color->get_value( 1));
1453 v[1] = green->get_value();
1454 mi::base::Handle<const mi::neuraylib::IValue_float> blue ( value_color->get_value( 2));
1455 v[2] = blue ->get_value();
1456 return 0;
1457 }
1458
1459 return -1;
1460}
1461
1474template<class T>
1476{
1479 if( value_compound) {
1480 mi::base::Handle<const mi::neuraylib::IValue> component( value_compound->get_value( index));
1481 if( !component)
1482 return -3;
1483 return get_value( component.get(), v);
1484 }
1485
1486 return -1;
1487}
1488
1501template<class T>
1502mi::Sint32 get_value( const mi::neuraylib::IValue* value, const char* name, T& v)
1503{
1506 if( value_struct) {
1507 mi::base::Handle<const mi::neuraylib::IValue> field( value_struct->get_field( name));
1508 if( !field)
1509 return -3;
1510 return get_value( field.get(), v);
1511 }
1512
1513 return -1;
1514}
1515
1528template<class T>
1530{
1533 if( value_array) {
1534 if( value_array->get_size() != n)
1535 return -5;
1536 for( mi::Size i = 0; i < n; ++i) {
1537 mi::base::Handle<const mi::neuraylib::IValue> element( value_array->get_value( i));
1538 mi::Sint32 result = get_value( element.get(), v[i]);
1539 if( result != 0)
1540 return result;
1541 }
1542 return 0;
1543 }
1544
1545 return -1;
1546}
1547
1548 // end group mi_neuray_mdl_types
1550
1551} // namespace neuraylib
1552
1553} // namespace mi
1554
1555#endif // MI_NEURAYLIB_IVALUE_H
A simple string class.
Definition: istring.h:22
Handle class template for interfaces, automatizing the lifetime control via reference counting.
Definition: handle.h:112
Mixin class template for deriving new interface declarations.
Definition: interface_declare.h:43
Standard RGBA color class with floating point elements and operations.
Definition: color.h:81
NxM-dimensional matrix class template of fixed dimensions.
Definition: matrix.h:367
Spectrum with floating point elements and operations.
Definition: spectrum.h:53
Fixed-size math vector class template with generic operations.
Definition: vector.h:286
An annotation block is an array of annotations.
Definition: iexpression.h:575
An annotation is similar to a direct call expression, but without return type.
Definition: iexpression.h:552
The type of kind array.
Definition: itype.h:449
An atomic type.
Definition: itype.h:255
The type of kind bool.
Definition: itype.h:262
The type of kind bsdf_measurement.
Definition: itype.h:580
The type of kind color.
Definition: itype.h:439
A compound type.
Definition: itype.h:380
The type of kind double.
Definition: itype.h:360
A type of kind enum.
Definition: itype.h:282
The interface for creating types.
Definition: itype.h:711
The type of kind float.
Definition: itype.h:350
The type of kind int.
Definition: itype.h:272
The type of kind light_profile.
Definition: itype.h:570
The type of kind matrix.
Definition: itype.h:424
The reference types.
Definition: itype.h:533
A string valued resource type.
Definition: itype.h:540
The type of kind string.
Definition: itype.h:370
The type of kind struct.
Definition: itype.h:472
The type of kind texture.
Definition: itype.h:547
The type of kind vector.
Definition: itype.h:396
The interface to MDL types.
Definition: itype.h:153
A value of type array.
Definition: ivalue.h:401
virtual Sint32 set_size(Size size)=0
Sets the size for deferred-sized arrays.
virtual const IType_array * get_type() const =0
Returns the type of this value.
static const Kind s_kind
The kind of this subclass.
Definition: ivalue.h:404
An atomic value.
Definition: ivalue.h:94
virtual const IType_atomic * get_type() const =0
Returns the type of this value.
A value of type boolean.
Definition: ivalue.h:104
static const Kind s_kind
The kind of this subclass.
Definition: ivalue.h:107
virtual const IType_bool * get_type() const =0
Returns the type of this value.
virtual bool get_value() const =0
Returns the value.
virtual void set_value(bool value)=0
Sets the value.
A BSDF measurement value.
Definition: ivalue.h:558
static const Kind s_kind
The kind of this subclass.
Definition: ivalue.h:561
virtual const IType_bsdf_measurement * get_type() const =0
Returns the type of this value.
A value of type color.
Definition: ivalue.h:372
virtual const IValue_float * get_value(Size index) const =0
Returns the value at index, or nullptr if index is out of bounds.
static const Kind s_kind
The kind of this subclass.
Definition: ivalue.h:375
virtual IValue_float * get_value(Size index)=0
Returns the value at index, or nullptr if index is out of bounds.
virtual Sint32 set_value(Size index, IValue_float *value)=0
Sets the value at index.
virtual const IType_color * get_type() const =0
Returns the type of this value.
A compound value.
Definition: ivalue.h:250
virtual Size get_size() const =0
Returns the number of components in this compound value.
virtual const IValue * get_value(Size index) const =0
Returns the value at index, or nullptr if index is out of bounds.
virtual IValue * get_value(Size index)=0
Returns the value at index, or nullptr if index is out of bounds.
T * get_value(Size index)
Returns the value at index, or nullptr if index is out of bounds.
Definition: ivalue.h:278
virtual const IType_compound * get_type() const =0
Returns the type of this value.
const T * get_value(Size index) const
Returns the value at index, or nullptr if index is out of bounds.
Definition: ivalue.h:263
virtual Sint32 set_value(Size index, IValue *value)=0
Sets the value at index.
A value of type double.
Definition: ivalue.h:200
static const Kind s_kind
The kind of this subclass.
Definition: ivalue.h:203
virtual Float64 get_value() const =0
Returns the value.
virtual void set_value(Float64 value)=0
Sets the value.
virtual const IType_double * get_type() const =0
Returns the type of this value.
A value of type enum.
Definition: ivalue.h:142
virtual const IType_enum * get_type() const =0
Returns the type of this value.
virtual Sint32 set_name(const char *name)=0
Sets the enum value by string representation in linear time.
virtual Sint32 set_value(Sint32 value)=0
Sets the enum value by integer in linear time.
virtual Sint32 get_value() const =0
Returns the (integer) value of this enum value.
virtual const char * get_name() const =0
Returns the string representation of this enum value.
virtual Sint32 set_index(Size index)=0
Sets the enum value by index.
static const Kind s_kind
The kind of this subclass.
Definition: ivalue.h:145
virtual Size get_index() const =0
Returns the index of this enum value.
The interface for creating values.
Definition: ivalue.h:658
virtual IValue_texture * create_texture(const IType_texture *type, const char *value) const =0
Creates a new texture value, or returns nullptr in case of errors.
virtual IValue_matrix * create_matrix(const IType_matrix *type) const =0
Creates a new value of type matrix, or returns nullptr in case of errors.
virtual const IString * dump(const IValue *value, const char *name, Size depth=0) const =0
Returns a textual representation of a value.
virtual const IString * dump(const IValue_list *list, const char *name, Size depth=0) const =0
Returns a textual representation of a value list.
virtual IValue * create(const IType *type, const IAnnotation_block *annotation_block) const =0
Creates a value observing a potentially present range annotation.
virtual IValue_list * clone(const IValue_list *value_list) const =0
Clones the given value list.
virtual IValue_string * create_string(const char *value="") const =0
Creates a new value of type string.
virtual Sint32 compare(const IValue_list *lhs, const IValue_list *rhs, Float64 epsilon=0.0) const =0
Compares two instances of mi::neuraylib::IValue_list.
virtual IValue_struct * create_struct(const IType_struct *type) const =0
Creates a new value of type struct, or returns nullptr in case of errors.
virtual IValue_invalid_df * create_invalid_df(const IType_reference *type) const =0
Creates a new invalid distribution function value.
T * create(const IType *type) const
Creates a default-constructed value of the given type.
Definition: ivalue.h:725
virtual IValue * clone(const IValue *value) const =0
Clones the given value.
virtual IValue * create(const IAnnotation *annotation) const =0
Creates a value observing the range of an "::anno::soft_range()" or an "::anno::hard_range()" annotat...
virtual Sint32 compare(const IValue *lhs, const IValue *rhs, Float64 epsilon=0.0) const =0
Compares two instances of mi::neuraylib::IValue.
T * clone(const T *value) const
Clones the given value.
Definition: ivalue.h:801
T * create(const IType *type, const IAnnotation_block *annotation_block) const
Creates a value observing a potentially present range annotation.
Definition: ivalue.h:775
virtual IValue_bool * create_bool(bool value=false) const =0
Creates a new value of type boolean.
virtual IValue_list * create_value_list() const =0
Creates a new value list.
virtual IValue_enum * create_enum(const IType_enum *type, Size index=0) const =0
Creates a new value of type enum, or returns nullptr in case of errors.
virtual IValue_bsdf_measurement * create_bsdf_measurement(const char *value) const =0
Creates a new BSDF measurement value, or returns nullptr in case of errors.
virtual IValue_vector * create_vector(const IType_vector *type) const =0
Creates a new value of type vector, or returns nullptr in case of errors.
virtual IValue_array * create_array(const IType_array *type) const =0
Creates a new value of type array, or returns nullptr in case of errors.
virtual IValue_int * create_int(Sint32 value=0) const =0
Creates a new value of type integer.
virtual IValue_float * create_float(Float32 value=0.0f) const =0
Creates a new value of type float.
virtual IValue_light_profile * create_light_profile(const char *value) const =0
Creates a new light profile value, or returns nullptr in case of errors.
virtual IType_factory * get_type_factory() const =0
Returns the type factory associated with this value factory.
T * create(const IAnnotation *annotation) const
Creates a value observing the range of an "::anno::soft_range()" or an "::anno::hard_range()" annotat...
Definition: ivalue.h:746
virtual IValue * create(const IType *type) const =0
Creates a default-constructed value of the given type.
virtual IValue_color * create_color(Float32 red=0.0f, Float32 green=0.0f, Float32 blue=0.0f) const =0
Creates a new value of type color.
virtual IValue_double * create_double(Float64 value=0.0) const =0
Creates a new value of type double.
A value of type float.
Definition: ivalue.h:181
virtual const IType_float * get_type() const =0
Returns the type of this value.
virtual Float32 get_value() const =0
Returns the value.
virtual void set_value(Float32 value)=0
Sets the value.
static const Kind s_kind
The kind of this subclass.
Definition: ivalue.h:184
A value of type integer.
Definition: ivalue.h:123
virtual const IType_int * get_type() const =0
Returns the type of this value.
virtual Sint32 get_value() const =0
Returns the value.
static const Kind s_kind
The kind of this subclass.
Definition: ivalue.h:126
virtual void set_value(Sint32 value)=0
Sets the value.
An invalid distribution function value.
Definition: ivalue.h:571
static const Kind s_kind
The kind of this subclass.
Definition: ivalue.h:574
virtual const IType_reference * get_type() const =0
Returns the type of this value.
A light profile value.
Definition: ivalue.h:545
virtual const IType_light_profile * get_type() const =0
Returns the type of this value.
static const Kind s_kind
The kind of this subclass.
Definition: ivalue.h:548
An ordered collection of values identified by name or index.
Definition: ivalue.h:585
virtual Size get_index(const char *name) const =0
Returns the index for the given name, or -1 if there is no such value.
const T * get_value(Size index) const
Returns the value for index, or nullptr if there is no such value.
Definition: ivalue.h:601
const T * get_value(const char *name) const
Returns the value for name, or nullptr if there is no such value.
Definition: ivalue.h:616
virtual Sint32 set_value(Size index, const IValue *value)=0
Sets a value at a given index.
virtual const char * get_name(Size index) const =0
Returns the name for the given index, or nullptr if there is no such value.
virtual const IValue * get_value(const char *name) const =0
Returns the value for name, or nullptr if there is no such value.
virtual Size get_size() const =0
Returns the number of elements.
virtual const IValue * get_value(Size index) const =0
Returns the value for index, or nullptr if there is no such value.
virtual Sint32 add_value(const char *name, const IValue *value)=0
Adds a value at the end of the list.
virtual Sint32 set_value(const char *name, const IValue *value)=0
Sets a value identified by name.
A value of type matrix.
Definition: ivalue.h:353
virtual const IValue_vector * get_value(Size index) const =0
Returns the value at index, or nullptr if index is out of bounds.
static const Kind s_kind
The kind of this subclass.
Definition: ivalue.h:356
virtual const IType_matrix * get_type() const =0
Returns the type of this value.
virtual IValue_vector * get_value(Size index)=0
Returns the value at index, or nullptr if index is out of bounds.
Base class for resource values.
Definition: ivalue.h:488
virtual const char * get_file_path() const =0
Returns the absolute MDL file path of the resource, or nullptr if not known.
virtual const IType_resource * get_type() const =0
Returns the type of this value.
virtual const char * get_value() const =0
Returns the name of the DB element representing this resource.
virtual Sint32 set_value(const char *value)=0
Sets the name of the DB element representing this resource.
A value of type string which can be used to obtain the original, non-localized value of a localized s...
Definition: ivalue.h:239
virtual const char * get_original_value() const =0
Returns the original value of a localized string.
A value of type string.
Definition: ivalue.h:219
virtual const char * get_value() const =0
Returns the value.
static const Kind s_kind
The kind of this subclass.
Definition: ivalue.h:222
virtual const IType_string * get_type() const =0
Returns the type of this value.
virtual void set_value(const char *value)=0
Sets the value.
A value of type struct.
Definition: ivalue.h:422
virtual Sint32 set_field(const char *name, IValue *value)=0
Sets a field by name in linear time.
virtual IValue * get_field(const char *name)=0
Returns a field by name in linear time.
static const Kind s_kind
The kind of this subclass.
Definition: ivalue.h:425
virtual const IType_struct * get_type() const =0
Returns the type of this value.
virtual const IValue * get_field(const char *name) const =0
Returns a field by name in linear time.
T * get_field(const char *name)
Returns a field by name in linear time.
Definition: ivalue.h:462
const T * get_field(const char *name) const
Returns a field by name in linear time.
Definition: ivalue.h:441
A texture value.
Definition: ivalue.h:523
static const Kind s_kind
The kind of this subclass.
Definition: ivalue.h:526
virtual const IType_texture * get_type() const =0
Returns the type of this value.
virtual Float32 get_gamma() const =0
Returns the gamma value of this texture.
virtual const char * get_selector() const =0
Returns the selector of this texture, or nullptr.
A value of type vector.
Definition: ivalue.h:307
const T * get_value(Size index) const
Returns the value at index, or nullptr if index is out of bounds.
Definition: ivalue.h:320
virtual IValue_atomic * get_value(Size index)=0
Returns the value at index, or nullptr if index is out of bounds.
static const Kind s_kind
The kind of this subclass.
Definition: ivalue.h:310
virtual const IType_vector * get_type() const =0
Returns the type of this value.
T * get_value(Size index)
Returns the value at index, or nullptr if index is out of bounds.
Definition: ivalue.h:335
virtual const IValue_atomic * get_value(Size index) const =0
Returns the value at index, or nullptr if index is out of bounds.
The interface to MDL values.
Definition: ivalue.h:34
virtual Kind get_kind() const =0
Returns the kind of the value.
const T * get_type() const
Returns the type of this value.
Definition: ivalue.h:79
virtual const IType * get_type() const =0
Returns the type of this value.
Kind
The possible kinds of values.
Definition: ivalue.h:37
@ VK_TEXTURE
A texture value. See mi::neuraylib::IValue_texture.
Definition: ivalue.h:63
@ VK_LIGHT_PROFILE
A light_profile value. See mi::neuraylib::IValue_light_profile.
Definition: ivalue.h:65
@ VK_ARRAY
An array value. See mi::neuraylib::IValue_array.
Definition: ivalue.h:57
@ VK_STRUCT
A struct value. See mi::neuraylib::IValue_struct.
Definition: ivalue.h:59
@ VK_FLOAT
A float value. See mi::neuraylib::IValue_float.
Definition: ivalue.h:45
@ VK_DOUBLE
A double value. See mi::neuraylib::IValue_double.
Definition: ivalue.h:47
@ VK_MATRIX
A matrix value. See mi::neuraylib::IValue_matrix.
Definition: ivalue.h:53
@ VK_BSDF_MEASUREMENT
A bsdf_measurement value. See mi::neuraylib::IValue_bsdf_measurement.
Definition: ivalue.h:67
@ VK_ENUM
An enum value. See mi::neuraylib::IValue_enum.
Definition: ivalue.h:43
@ VK_INT
An integer value. See mi::neuraylib::IValue_int.
Definition: ivalue.h:41
@ VK_VECTOR
A vector value. See mi::neuraylib::IValue_vector.
Definition: ivalue.h:51
@ VK_INVALID_DF
An invalid distribution function value. See mi::neuraylib::IValue_invalid_df.
Definition: ivalue.h:61
@ VK_BOOL
A boolean value. See mi::neuraylib::IValue_bool.
Definition: ivalue.h:39
@ VK_STRING
A string value. See mi::neuraylib::IValue_string.
Definition: ivalue.h:49
@ VK_COLOR
A color value. See mi::neuraylib::IValue_color.
Definition: ivalue.h:55
Standard RGBA color class with floating point elements and operations.
virtual const IInterface * get_interface(const Uuid &interface_id) const =0
Acquires a const interface from another.
Interface * get() const
Access to the interface. Returns 0 for an invalid interface.
Definition: handle.h:289
virtual Uint32 release() const =0
Decrements the reference count.
int Sint32
32-bit signed integer.
Definition: types.h:46
float Float32
32-bit float.
Definition: types.h:51
double Float64
64-bit float.
Definition: types.h:52
Uint64 Size
Unsigned integral type that is large enough to hold the size of all types.
Definition: types.h:112
unsigned int Uint32
32-bit unsigned integer.
Definition: types.h:49
Float32 g
Green color component.
Definition: vector.h:71
Float32 a
Alpha value, 0.0 is fully transparent and 1.0 is opaque; value can lie outside that range.
Definition: vector.h:75
Float32 r
Red color component.
Definition: vector.h:69
Float32 b
Blue color component.
Definition: vector.h:73
mi::Sint32 set_value(mi::neuraylib::IValue *value, const T &v)
Simplifies setting the value of mi::neuraylib::IValue from the corresponding classes from the base an...
Definition: ivalue.h:924
mi::Sint32 get_value(const mi::neuraylib::IValue *value, T &v)
Simplifies reading the value of mi::neuraylib::IValue into the corresponding classes from the base an...
Definition: ivalue.h:1253
Smart-pointer handle class for interfaces, const and non-const version.
Types of the MDL type system.
A NxM-dimensional matrix class template of fixed dimensions with supporting functions.
Common namespace for APIs of NVIDIA Advanced Rendering Center GmbH.
Definition: example_derivatives.dox:5
Major and minor version number and an optional qualifier.
Spectrum class with floating point elements and operations.
Math vector class template of fixed dimension with arithmetic operators and generic functions.