MDL SDK API nvidia_logo_transpbg.gif Up
ivalue.h
Go to the documentation of this file.
1/***************************************************************************************************
2 * Copyright 2023 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
17namespace mi {
18
19namespace neuraylib {
20
25class IAnnotation;
26class IAnnotation_block;
27
31class IValue : public
32 mi::base::Interface_declare<0xbf837f4a,0x9034,0x4f32,0xaf,0x5c,0x75,0xb3,0x67,0x64,0x53,0x23>
33{
34public:
36 enum Kind {
67 // Undocumented, for alignment only.
68 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
90mi_static_assert( sizeof( IValue::Kind) == sizeof( Uint32));
91
93class IValue_atomic : public
94 mi::base::Interface_declare<0xf2413c80,0x8e71,0x4974,0xaa,0xf2,0x60,0xd5,0xe2,0x94,0x9d,0x3e,
95 neuraylib::IValue>
96{
97public:
99 const IType_atomic* get_type() const = 0;
100};
101
103class IValue_bool : public
104 mi::base::Interface_declare<0xaf253a14,0x1f04,0x4b67,0xba,0x70,0x7b,0x01,0x05,0xfb,0xc8,0xf5,
105 neuraylib::IValue_atomic>
106{
107public:
109 static const Kind s_kind = VK_BOOL;
110
112 const IType_bool* get_type() const = 0;
113
115 virtual bool get_value() const = 0;
116
118 virtual void set_value( bool value) = 0;
119};
120
122class IValue_int : public
123 mi::base::Interface_declare<0x91e6f145,0x280d,0x4d68,0x95,0x57,0xe1,0xd0,0x9c,0xd2,0x5c,0x74,
124 neuraylib::IValue_atomic>
125{
126public:
128 static const Kind s_kind = VK_INT;
129
131 const IType_int* get_type() const = 0;
132
134 virtual Sint32 get_value() const = 0;
135
137 virtual void set_value( Sint32 value) = 0;
138};
139
141class IValue_enum : public
142 mi::base::Interface_declare<0xdc876204,0x8a97,0x40e9,0xb9,0xb6,0xca,0xdc,0xdd,0x60,0x1f,0xbf,
143 neuraylib::IValue_atomic>
144{
145public:
147 static const Kind s_kind = VK_ENUM;
148
150 virtual const IType_enum* get_type() const = 0;
151
153 virtual Sint32 get_value() const = 0;
154
156 virtual Size get_index() const = 0;
157
163 virtual Sint32 set_value( Sint32 value) = 0;
164
168 virtual Sint32 set_index( Size index) = 0;
169
171 virtual const char* get_name() const = 0;
172
176 virtual Sint32 set_name( const char* name) = 0;
177};
178
180class IValue_float : public
181 mi::base::Interface_declare<0x21f07151,0x74b5,0x4296,0x90,0x29,0xc7,0xde,0x49,0x38,0x2a,0xbc,
182 neuraylib::IValue_atomic>
183{
184public:
186 static const Kind s_kind = VK_FLOAT;
187
189 const IType_float* get_type() const = 0;
190
192 virtual Float32 get_value() const = 0;
193
195 virtual void set_value( Float32 value) = 0;
196};
197
199class IValue_double : public
200 mi::base::Interface_declare<0xbdc84417,0x3e83,0x4bab,0x90,0xb1,0x9f,0x57,0xed,0x7b,0x15,0x03,
201 neuraylib::IValue_atomic>
202{
203public:
205 static const Kind s_kind = VK_DOUBLE;
206
208 const IType_double* get_type() const = 0;
209
211 virtual Float64 get_value() const = 0;
212
214 virtual void set_value( Float64 value) = 0;
215};
216
218class IValue_string : public
219 mi::base::Interface_declare<0x64b28506,0x8675,0x4724,0xa1,0x0d,0xc6,0xf2,0x35,0x46,0x26,0x39,
220 neuraylib::IValue_atomic>
221{
222public:
224 static const Kind s_kind = VK_STRING;
225
227 const IType_string* get_type() const = 0;
228
230 virtual const char* get_value() const = 0;
231
233 virtual void set_value( const char* value) = 0;
234};
235
239 mi::base::Interface_declare<0x1fe80d3d,0xe79e,0x4bdb,0xb6,0x30,0xe3,0x36,0x31,0xa4,0x1e,0x39,
240 neuraylib::IValue_string>
241{
242public:
245 virtual const char* get_original_value() const = 0;
246};
247
249class IValue_compound : public
250 mi::base::Interface_declare<0xdabc8fe3,0x5c70,0x4ef0,0xa2,0xf7,0x34,0x30,0xb5,0x67,0xdc,0x75,
251 neuraylib::IValue>
252{
253public:
255 virtual const IType_compound* get_type() const = 0;
256
258 virtual Size get_size() const = 0;
259
261 virtual const IValue* get_value( Size index) const = 0;
262
264 template <class T>
265 const T* get_value( Size index) const
266 {
267 const IValue* ptr_value = get_value( index);
268 if( !ptr_value)
269 return 0;
270 const T* ptr_T = static_cast<const T*>( ptr_value->get_interface( typename T::IID()));
271 ptr_value->release();
272 return ptr_T;
273 }
274
276 virtual IValue* get_value( Size index) = 0;
277
279 template <class T>
280 T* get_value( Size index)
281 {
282 IValue* ptr_value = get_value( index);
283 if( !ptr_value)
284 return 0;
285 T* ptr_T = static_cast<T*>( ptr_value->get_interface( typename T::IID()));
286 ptr_value->release();
287 return ptr_T;
288 }
289
299 virtual Sint32 set_value( Size index, IValue* value) = 0;
300};
301
306class IValue_vector : public
307 mi::base::Interface_declare<0xf5d09fc3,0xd783,0x4571,0x8d,0x59,0x41,0xb1,0xff,0xd3,0x91,0x49,
308 neuraylib::IValue_compound>
309{
310public:
312 static const Kind s_kind = VK_VECTOR;
313
315 virtual const IType_vector* get_type() const = 0;
316
318 virtual const IValue_atomic* get_value( Size index) const = 0;
319
321 template <class T>
322 const T* get_value( Size index) const
323 {
324 const IValue_atomic* ptr_value = get_value( index);
325 if( !ptr_value)
326 return 0;
327 const T* ptr_T = static_cast<const T*>( ptr_value->get_interface( typename T::IID()));
328 ptr_value->release();
329 return ptr_T;
330 }
331
333 virtual IValue_atomic* get_value( Size index) = 0;
334
336 template <class T>
337 T* get_value( Size index)
338 {
339 IValue_atomic* ptr_value = get_value( index);
340 if( !ptr_value)
341 return 0;
342 T* ptr_T = static_cast<T*>( ptr_value->get_interface( typename T::IID()));
343 ptr_value->release();
344 return ptr_T;
345 }
346};
347
352class IValue_matrix : public
353 mi::base::Interface_declare<0x9ee95da6,0x2cd6,0x4168,0x89,0xea,0x92,0x10,0x57,0xda,0xe6,0xdc,
354 neuraylib::IValue_compound>
355{
356public:
358 static const Kind s_kind = VK_MATRIX;
359
361 virtual const IType_matrix* get_type() const = 0;
362
364 virtual const IValue_vector* get_value( Size index) const = 0;
365
367 virtual IValue_vector* get_value( Size index) = 0;
368};
369
371class IValue_color : public
372 mi::base::Interface_declare<0x3bb9bf46,0x1cbb,0x4460,0xbe,0x27,0x10,0xf5,0x71,0x61,0x96,0xa2,
373 neuraylib::IValue_compound>
374{
375public:
377 static const Kind s_kind = VK_COLOR;
378
380 virtual const IType_color* get_type() const = 0;
381
383 virtual const IValue_float* get_value( Size index) const = 0;
384
386 virtual IValue_float* get_value( Size index) = 0;
387
394 virtual Sint32 set_value( Size index, IValue_float* value) = 0;
395
397};
398
400class IValue_array : public
401 mi::base::Interface_declare<0xa17c5f57,0xa647,0x41c4,0x86,0x2f,0x4c,0x0d,0xe1,0x30,0x08,0xfc,
402 neuraylib::IValue_compound>
403{
404public:
406 static const Kind s_kind = VK_ARRAY;
407
409 virtual const IType_array* get_type() const = 0;
410
417 virtual Sint32 set_size( Size size) = 0;
418};
419
421class IValue_struct : public
422 mi::base::Interface_declare<0xcbe089ce,0x4aea,0x474d,0x94,0x5f,0x52,0x13,0xef,0x01,0xce,0x81,
423 neuraylib::IValue_compound>
424{
425public:
427 static const Kind s_kind = VK_STRUCT;
428
430 virtual const IType_struct* get_type() const = 0;
431
436 virtual const IValue* get_field( const char* name) const = 0;
437
442 template <class T>
443 const T* get_field( const char* name) const
444 {
445 const IValue* ptr_value = get_field( name);
446 if( !ptr_value)
447 return 0;
448 T* ptr_T = static_cast<T*>( ptr_value->get_interface( typename T::IID()));
449 ptr_value->release();
450 return ptr_T;
451 }
452
457 virtual IValue* get_field( const char* name) = 0;
458
463 template <class T>
464 T* get_field( const char* name)
465 {
466 IValue* ptr_value = get_field( name);
467 if( !ptr_value)
468 return 0;
469 T* ptr_T = static_cast<T*>( ptr_value->get_interface( typename T::IID()));
470 ptr_value->release();
471 return ptr_T;
472 }
473
483 virtual Sint32 set_field( const char* name, IValue* value) = 0;
484};
485
487class IValue_resource : public
488 mi::base::Interface_declare<0x479bb10c,0xd444,0x426c,0x83,0xab,0x26,0xdf,0xf6,0x1d,0x6f,0xd7,
489 neuraylib::IValue>
490{
491public:
493 virtual const IType_resource* get_type() const = 0;
494
498 virtual const char* get_value() const = 0;
499
510 virtual Sint32 set_value( const char* value) = 0;
511
516 virtual const char* get_file_path() 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 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 0;
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
875 virtual const IString* dump( const IValue* value, const char* name, Size depth = 0) const = 0;
876
886 virtual const IString* dump(
887 const IValue_list* list, const char* name, Size depth = 0) const = 0;
888
890};
891
922template<class T>
924{
927 if( value_int) {
928 value_int->set_value( v);
929 return 0;
930 }
931
934 if( value_enum) {
935 if( value_enum->set_value( v) != 0)
936 return -2;
937 return 0;
938 }
939
940 return -1;
941}
942
946inline mi::Sint32 set_value( mi::neuraylib::IValue* value, const bool& v)
947{
950 if( value_bool) {
951 value_bool->set_value( v);
952 return 0;
953 }
954
955 return -1;
956}
957
962{
965 if( value_float) {
966 value_float->set_value( v);
967 return 0;
968 }
969
972 if( value_double) {
973 value_double->set_value( v);
974 return 0;
975 }
976
977 return -1;
978}
979
984{
987 if( value_float) {
988 value_float->set_value( static_cast<mi::Float32>( v));
989 return 0;
990 }
991
994 if( value_double) {
995 value_double->set_value( v);
996 return 0;
997 }
998
999 return -1;
1000}
1001
1006inline mi::Sint32 set_value( mi::neuraylib::IValue* value, const char* v)
1007{
1010 if( value_enum) {
1011 if( value_enum->set_name( v) != 0)
1012 return -2;
1013 return 0;
1014 }
1015
1018 if( value_string) {
1019 value_string->set_value( v);
1020 return 0;
1021 }
1022
1025 if( value_resource) {
1026 if( value_resource->set_value( v) != 0)
1027 return -2;
1028 return 0;
1029 }
1030
1031 return -1;
1032}
1033
1038template<class T, Size DIM>
1040{
1043 if( value_vector) {
1044 if( value_vector->get_size() != DIM)
1045 return -1;
1046 for( Size i = 0; i < DIM; ++i) {
1047 mi::base::Handle<mi::neuraylib::IValue> component( value_vector->get_value( i));
1048 mi::Sint32 result = set_value( component.get(), v[i]);
1049 if( result != 0)
1050 return result;
1051 }
1052 return 0;
1053 }
1054
1055 return -1;
1056}
1057
1067template<class T, Size ROW, Size COL>
1069{
1072 if( value_matrix) {
1073 if( value_matrix->get_size() != ROW)
1074 return -1;
1075 for( Size i = 0; i < ROW; ++i) {
1076 mi::base::Handle<mi::neuraylib::IValue_vector> column( value_matrix->get_value( i));
1077 if( column->get_size() != COL)
1078 return -1;
1079 for( Size j = 0; j < COL; ++j) {
1080 mi::base::Handle<mi::neuraylib::IValue> element( column->get_value( j));
1081 mi::Sint32 result = set_value( element.get(), v[i][j]);
1082 if( result != 0)
1083 return result;
1084 }
1085 }
1086 return 0;
1087 }
1088
1089 return -1;
1090}
1091
1096{
1099 if( value_color) {
1100 mi::base::Handle<mi::neuraylib::IValue_float> red ( value_color->get_value( 0));
1101 red ->set_value( v.r);
1102 mi::base::Handle<mi::neuraylib::IValue_float> green( value_color->get_value( 1));
1103 green->set_value( v.g);
1104 mi::base::Handle<mi::neuraylib::IValue_float> blue ( value_color->get_value( 2));
1105 blue ->set_value( v.b);
1106 return 0;
1107 }
1108
1109 return -1;
1110}
1111
1117{
1120 if( value_color) {
1121 mi::base::Handle<mi::neuraylib::IValue_float> red ( value_color->get_value( 0));
1122 red ->set_value( v[0]);
1123 mi::base::Handle<mi::neuraylib::IValue_float> green( value_color->get_value( 1));
1124 green->set_value( v[1]);
1125 mi::base::Handle<mi::neuraylib::IValue_float> blue ( value_color->get_value( 2));
1126 blue ->set_value( v[2]);
1127 return 0;
1128 }
1129
1130 return -1;
1131}
1132
1145template<class T>
1147{
1150 if( value_compound) {
1151 mi::base::Handle<mi::neuraylib::IValue> component( value_compound->get_value( index));
1152 if( !component)
1153 return -3;
1154 return set_value( component.get(), v);
1155 }
1156
1157 return -1;
1158}
1159
1172template<class T>
1173mi::Sint32 set_value( mi::neuraylib::IValue* value, const char* name, const T& v)
1174{
1177 if( value_struct) {
1178 mi::base::Handle<mi::neuraylib::IValue> field( value_struct->get_field( name));
1179 if( !field)
1180 return -3;
1181 return set_value( field.get(), v);
1182 }
1183
1184 return -1;
1185}
1186
1199template<class T>
1201{
1204 if( value_array) {
1205 if( value_array->get_size() != n)
1206 return -3;
1207 for( mi::Size i = 0; i < n; ++i) {
1208 mi::base::Handle<mi::neuraylib::IValue> element( value_array->get_value( i));
1209 mi::Sint32 result = set_value( element.get(), v[i]);
1210 if( result != 0)
1211 return result;
1212 }
1213 return 0;
1214 }
1215
1216 return -1;
1217}
1218
1248template<class T>
1250{
1253 if( value_int) {
1254 v = value_int->get_value();
1255 return 0;
1256 }
1257
1260 if( value_enum) {
1261 v = value_enum->get_value();
1262 return 0;
1263 }
1264
1265 return -1;
1266}
1267
1271inline mi::Sint32 get_value( const mi::neuraylib::IValue* value, bool& v)
1272{
1275 if( value_bool) {
1276 v = value_bool->get_value();
1277 return 0;
1278 }
1279
1280 return -1;
1281}
1282
1287{
1290 if( value_float) {
1291 v = value_float->get_value();
1292 return 0;
1293 }
1294
1297 if( value_double) {
1298 v = static_cast<mi::Float32>( value_double->get_value());
1299 return 0;
1300 }
1301
1302 return -1;
1303}
1304
1309{
1312 if( value_float) {
1313 v = value_float->get_value();
1314 return 0;
1315 }
1316
1319 if( value_double) {
1320 v = value_double->get_value();
1321 return 0;
1322 }
1323
1324 return -1;
1325}
1326
1331inline mi::Sint32 get_value( const mi::neuraylib::IValue* value, const char*& v)
1332{
1335 if( value_enum) {
1336 v = value_enum->get_name();
1337 return 0;
1338 }
1339
1342 if( value_string) {
1343 v = value_string->get_value();
1344 return 0;
1345 }
1346
1349 if( value_resource) {
1350 v = value_resource->get_value();
1351 return 0;
1352 }
1353
1354 return -1;
1355}
1356
1361template <class T, Size DIM>
1363{
1366 if( value_vector) {
1367 if( value_vector->get_size() != DIM)
1368 return -1;
1369 for( Size i = 0; i < DIM; ++i) {
1370 mi::base::Handle<const mi::neuraylib::IValue> component( value_vector->get_value( i));
1371 mi::Sint32 result = get_value( component.get(), v[i]);
1372 if( result != 0)
1373 return result;
1374 }
1375 return 0;
1376 }
1377
1378 return -1;
1379}
1380
1390template <class T, Size ROW, Size COL>
1392{
1395 if( value_matrix) {
1396 if( value_matrix->get_size() != ROW)
1397 return -1;
1398 for( Size i = 0; i < ROW; ++i) {
1400 value_matrix->get_value( i));
1401 if( column->get_size() != COL)
1402 return -1;
1403 for( Size j = 0; j < COL; ++j) {
1404 mi::base::Handle<const mi::neuraylib::IValue> element( column->get_value( j));
1405 mi::Sint32 result = get_value( element.get(), v[i][j]);
1406 if( result != 0)
1407 return result;
1408 }
1409 }
1410 return 0;
1411 }
1412
1413 return -1;
1414}
1415
1420{
1423 if( value_color) {
1424 mi::base::Handle<const mi::neuraylib::IValue_float> red ( value_color->get_value( 0));
1425 v.r = red ->get_value();
1426 mi::base::Handle<const mi::neuraylib::IValue_float> green( value_color->get_value( 1));
1427 v.g = green->get_value();
1428 mi::base::Handle<const mi::neuraylib::IValue_float> blue ( value_color->get_value( 2));
1429 v.b = blue ->get_value();
1430 v.a = 1.0f;
1431 return 0;
1432 }
1433
1434 return -1;
1435}
1436
1442{
1445 if( value_color) {
1446 mi::base::Handle<const mi::neuraylib::IValue_float> red ( value_color->get_value( 0));
1447 v[0] = red ->get_value();
1448 mi::base::Handle<const mi::neuraylib::IValue_float> green( value_color->get_value( 1));
1449 v[1] = green->get_value();
1450 mi::base::Handle<const mi::neuraylib::IValue_float> blue ( value_color->get_value( 2));
1451 v[2] = blue ->get_value();
1452 return 0;
1453 }
1454
1455 return -1;
1456}
1457
1470template<class T>
1472{
1475 if( value_compound) {
1476 mi::base::Handle<const mi::neuraylib::IValue> component( value_compound->get_value( index));
1477 if( !component)
1478 return -3;
1479 return get_value( component.get(), v);
1480 }
1481
1482 return -1;
1483}
1484
1497template<class T>
1498mi::Sint32 get_value( const mi::neuraylib::IValue* value, const char* name, T& v)
1499{
1502 if( value_struct) {
1503 mi::base::Handle<const mi::neuraylib::IValue> field( value_struct->get_field( name));
1504 if( !field)
1505 return -3;
1506 return get_value( field.get(), v);
1507 }
1508
1509 return -1;
1510}
1511
1524template<class T>
1526{
1529 if( value_array) {
1530 if( value_array->get_size() != n)
1531 return -3;
1532 for( mi::Size i = 0; i < n; ++i) {
1533 mi::base::Handle<const mi::neuraylib::IValue> element( value_array->get_value( i));
1534 mi::Sint32 result = get_value( element.get(), v[i]);
1535 if( result != 0)
1536 return result;
1537 }
1538 return 0;
1539 }
1540
1541 return -1;
1542}
1543
1544 // end group mi_neuray_mdl_types
1546
1547} // namespace neuraylib
1548
1549} // namespace mi
1550
1551#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:113
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:546
An annotation is similar to a direct call expression, but without return type.
Definition: iexpression.h:523
The type of kind array.
Definition: itype.h:349
An atomic type.
Definition: itype.h:154
The type of kind bool.
Definition: itype.h:161
The type of kind bsdf_measurement.
Definition: itype.h:484
The type of kind color.
Definition: itype.h:339
A compound type.
Definition: itype.h:280
The type of kind double.
Definition: itype.h:260
A type of kind enum.
Definition: itype.h:181
The interface for creating types.
Definition: itype.h:612
The type of kind float.
Definition: itype.h:250
The type of kind int.
Definition: itype.h:171
The type of kind light_profile.
Definition: itype.h:474
The type of kind matrix.
Definition: itype.h:324
The reference types.
Definition: itype.h:434
A string valued resource type.
Definition: itype.h:441
The type of kind string.
Definition: itype.h:270
The type of kind struct.
Definition: itype.h:374
The type of kind texture.
Definition: itype.h:448
The type of kind vector.
Definition: itype.h:296
The interface to MDL types.
Definition: itype.h:51
A value of type array.
Definition: ivalue.h:403
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:406
An atomic value.
Definition: ivalue.h:96
const IType_atomic * get_type() const =0
Returns the type of this value.
A value of type boolean.
Definition: ivalue.h:106
static const Kind s_kind
The kind of this subclass.
Definition: ivalue.h:109
virtual bool get_value() const =0
Returns the value.
virtual void set_value(bool value)=0
Sets the value.
const IType_bool * get_type() const =0
Returns the type of this 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:374
virtual const IValue_float * get_value(Size index) const =0
Returns the value at index, or NULL if index is out of bounds.
static const Kind s_kind
The kind of this subclass.
Definition: ivalue.h:377
virtual IValue_float * get_value(Size index)=0
Returns the value at index, or NULL 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:252
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 NULL if index is out of bounds.
virtual IValue * get_value(Size index)=0
Returns the value at index, or NULL if index is out of bounds.
T * get_value(Size index)
Returns the value at index, or NULL if index is out of bounds.
Definition: ivalue.h:280
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 NULL if index is out of bounds.
Definition: ivalue.h:265
virtual Sint32 set_value(Size index, IValue *value)=0
Sets the value at index.
A value of type double.
Definition: ivalue.h:202
static const Kind s_kind
The kind of this subclass.
Definition: ivalue.h:205
virtual Float64 get_value() const =0
Returns the value.
virtual void set_value(Float64 value)=0
Sets the value.
const IType_double * get_type() const =0
Returns the type of this value.
A value of type enum.
Definition: ivalue.h:144
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:147
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 NULL in case of errors.
virtual IValue_matrix * create_matrix(const IType_matrix *type) const =0
Creates a new value of type matrix, or returns NULL 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 NULL 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 NULL in case of errors.
virtual IValue_bsdf_measurement * create_bsdf_measurement(const char *value) const =0
Creates a new BSDF measurement value, or returns NULL in case of errors.
virtual IValue_vector * create_vector(const IType_vector *type) const =0
Creates a new value of type vector, or returns NULL in case of errors.
virtual IValue_array * create_array(const IType_array *type) const =0
Creates a new value of type array, or returns NULL 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 NULL 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:183
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:186
A value of type integer.
Definition: ivalue.h:125
virtual Sint32 get_value() const =0
Returns the value.
static const Kind s_kind
The kind of this subclass.
Definition: ivalue.h:128
virtual void set_value(Sint32 value)=0
Sets the value.
const IType_int * get_type() const =0
Returns the type of this value.
An invalid distribution function value.
Definition: ivalue.h:571
const IType_reference * get_type() const =0
Returns the type of this value.
static const Kind s_kind
The kind of this subclass.
Definition: ivalue.h:574
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 NULL if there is no such value.
Definition: ivalue.h:601
const T * get_value(const char *name) const
Returns the value for name, or NULL 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 NULL if there is no such value.
virtual const IValue * get_value(const char *name) const =0
Returns the value for name, or NULL 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 NULL 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:355
virtual const IValue_vector * get_value(Size index) const =0
Returns the value at index, or NULL if index is out of bounds.
static const Kind s_kind
The kind of this subclass.
Definition: ivalue.h:358
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 NULL if index is out of bounds.
Base class for resource values.
Definition: ivalue.h:490
virtual const char * get_file_path() const =0
Returns the absolute MDL file path of the resource, or NULL 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:241
virtual const char * get_original_value() const =0
Returns the original value of a localized string.
A value of type string.
Definition: ivalue.h:221
const IType_string * get_type() const =0
Returns the type of this value.
virtual const char * get_value() const =0
Returns the value.
static const Kind s_kind
The kind of this subclass.
Definition: ivalue.h:224
virtual void set_value(const char *value)=0
Sets the value.
A value of type struct.
Definition: ivalue.h:424
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:427
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:464
const T * get_field(const char *name) const
Returns a field by name in linear time.
Definition: ivalue.h:443
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 NULL.
A value of type vector.
Definition: ivalue.h:309
const T * get_value(Size index) const
Returns the value at index, or NULL if index is out of bounds.
Definition: ivalue.h:322
virtual IValue_atomic * get_value(Size index)=0
Returns the value at index, or NULL if index is out of bounds.
static const Kind s_kind
The kind of this subclass.
Definition: ivalue.h:312
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 NULL if index is out of bounds.
Definition: ivalue.h:337
virtual const IValue_atomic * get_value(Size index) const =0
Returns the value at index, or NULL if index is out of bounds.
The interface to MDL values.
Definition: ivalue.h:33
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:36
@ VK_TEXTURE
A texture value. See mi::neuraylib::IValue_texture.
Definition: ivalue.h:62
@ VK_LIGHT_PROFILE
A light_profile value. See mi::neuraylib::IValue_light_profile.
Definition: ivalue.h:64
@ VK_ARRAY
An array value. See mi::neuraylib::IValue_array.
Definition: ivalue.h:56
@ VK_STRUCT
A struct value. See mi::neuraylib::IValue_struct.
Definition: ivalue.h:58
@ VK_FLOAT
A float value. See mi::neuraylib::IValue_float.
Definition: ivalue.h:44
@ VK_DOUBLE
A double value. See mi::neuraylib::IValue_double.
Definition: ivalue.h:46
@ VK_MATRIX
A matrix value. See mi::neuraylib::IValue_matrix.
Definition: ivalue.h:52
@ VK_BSDF_MEASUREMENT
A bsdf_measurement value. See mi::neuraylib::IValue_bsdf_measurement.
Definition: ivalue.h:66
@ VK_ENUM
An enum value. See mi::neuraylib::IValue_enum.
Definition: ivalue.h:42
@ VK_INT
An integer value. See mi::neuraylib::IValue_int.
Definition: ivalue.h:40
@ VK_VECTOR
A vector value. See mi::neuraylib::IValue_vector.
Definition: ivalue.h:50
@ VK_INVALID_DF
An invalid distribution function value. See mi::neuraylib::IValue_invalid_df.
Definition: ivalue.h:60
@ VK_BOOL
A boolean value. See mi::neuraylib::IValue_bool.
Definition: ivalue.h:38
@ VK_STRING
A string value. See mi::neuraylib::IValue_string.
Definition: ivalue.h:48
@ VK_COLOR
A color value. See mi::neuraylib::IValue_color.
Definition: ivalue.h:54
Standard RGBA color class with floating point elements and operations.
#define mi_static_assert(expr)
Compile time assertion that raises a compilation error if the constant expression expr evaluates to f...
Definition: assert.h:65
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:294
virtual Uint32 release() const =0
Decrements the reference count.
unsigned int Uint32
32-bit unsigned integer.
Definition: types.h:49
Uint64 Size
Unsigned integral type that is large enough to hold the size of all types.
Definition: types.h:112
double Float64
64-bit float.
Definition: types.h:52
float Float32
32-bit float.
Definition: types.h:51
signed int Sint32
32-bit signed integer.
Definition: types.h:46
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:923
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:1249
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
Spectrum class with floating point elements and operations.
Math vector class template of fixed dimension with arithmetic operators and generic functions.