neuray API Programmer's Manual

mi::neuraylib::IValue_factory Class Reference

[MDL type system]

Description

The interface for creating values. A value factory can be obtained from mi::neuraylib::IMdl_factory::create_value_factory().

See also:

mi::neuraylib::IType_factory, mi::neuraylib::IExpression_factory

Access to related factories.

virtual IType_factoryget_type_factory() const =0
Returns the type factory associated with this value factory.

Creation of values and value lists

virtual IValuecreate( const IType* type) const =0
Creates a default-constructed value of the given type.
template< class T>T* create( const IType* type) const
Creates a default-constructed value of the given type.
virtual IValuecreate( const IAnnotation* annotation) const =0
Creates a value observing the range of an "::anno::soft_range()" or an "::anno::hard_range()" annotation. More...
template< class T>T* create( const IAnnotation* annotation) const
Creates a value observing the range of an "::anno::soft_range()" or an "::anno::hard_range()" annotation. More...
virtual IValuecreate( const IType* type, const IAnnotation_block* annotation_block) const =0
Creates a value observing a potentially present range annotation. More...
template< class T>T* create( const IType* type, const IAnnotation_block* annotation_block) const
Creates a value observing a potentially present range annotation. More...
virtual IValue_arraycreate_array( const IType_array* type) const =0
Creates a new value of type array, or returns NULL in case of errors.
virtual IValue_boolcreate_bool( bool value = false) const =0
Creates a new value of type boolean.
virtual IValue_bsdf_measurementcreate_bsdf_measurement( const char* value) const =0
Creates a new BSDF measurement value, or returns NULL in case of errors.
virtual IValue_colorcreate_color( Float32 red = 0.0f, Float32 green = 0.0f, Float32 blue = 0.0f) const =0
Creates a new value of type color.
virtual IValue_doublecreate_double( Float64 value = 0.0) const =0
Creates a new value of type double.
virtual IValue_enumcreate_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_floatcreate_float( Float32 value = 0.0f) const =0
Creates a new value of type float.
virtual IValue_intcreate_int( Sint32 value = 0) const =0
Creates a new value of type integer.
virtual IValue_invalid_dfcreate_invalid_df( const IType_reference* type) const =0
Creates a new invalid distribution function value.
virtual IValue_light_profilecreate_light_profile( const char* value) const =0
Creates a new light profile value, or returns NULL in case of errors.
virtual IValue_matrixcreate_matrix( const IType_matrix* type) const =0
Creates a new value of type matrix, or returns NULL in case of errors.
virtual IValue_stringcreate_string( const char* value = "") const =0
Creates a new value of type string. More...
virtual IValue_structcreate_struct( const IType_struct* type) const =0
Creates a new value of type struct, or returns NULL in case of errors.
virtual IValue_texturecreate_texture( const IType_texture* type, const char* value) const =0
Creates a new texture value, or returns NULL in case of errors.
virtual IValue_listcreate_value_list() const =0
Creates a new value list.
virtual IValue_vectorcreate_vector( const IType_vector* type) const =0
Creates a new value of type vector, or returns NULL in case of errors.

Cloning of values and value lists

virtual IValueclone( const IValue* value) const =0
Clones the given value. More...
template< class T>T* clone( const T* value) const
Clones the given value. More...
virtual IValue_listclone( const IValue_list* value_list) const =0
Clones the given value list. More...

Comparison of values and value lists

virtual Sint32 compare( const IValue* lhs, const IValue* rhs, Float64 epsilon = 0.0) const =0
Compares two instances of mi::neuraylib::IValue. More...
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. More...

Dumping of values and value lists

virtual const IStringdump( const IValue* value, const char* name, Size depth = 0) const =0
Returns a textual representation of a value. More...
virtual const IStringdump( const IValue_list* list, const char* name, Size depth = 0) const =0
Returns a textual representation of a value list. More...

Member Functions

virtual IValue* mi::​neuraylib::​IValue_factory::clone( const IValue* value) const [pure virtual]

Clones the given value. Note that referenced DB elements, e.g., resources, are not copied, but shared.

template< class T>

T* mi::​neuraylib::​IValue_factory::clone( const T* value) const [inline]

Clones the given value. Note that referenced DB elements, e.g., resources, are not copied, but shared.

virtual IValue_list* mi::​neuraylib::​IValue_factory::clone( const IValue_list* value_list) const [pure virtual]

Clones the given value list. Note that referenced DB elements, e.g., resources, are not copied, but shared.

virtual Sint32 mi::​neuraylib::​IValue_factory::compare( const IValue* lhs, const IValue* rhs, Float64 epsilon = 0.0) const [pure virtual]

Compares two instances of mi::neuraylib::IValue. The comparison operator for instances of mi::neuraylib::IValue is defined as follows:

  • If lhs or rhs is NULL, the result is the lexicographic comparison of the pointer addresses themselves.

  • Otherwise, the types of lhs and rhs are compared. If they are different, the result is determined by that comparison.

  • Next, the kind of the values are compared. If they are different, the result is determined by operator< on the mi::neuraylib::IValue::Kind values.

  • Finally, the values are compared as follows:
    • For atomic types, their values are compared using operator< or strcmp(), with the exception of enums, for which the indices rather than the values are compared.

    • For compounds, the compound size is compared using operator< (the compound size might be different for deferred-sized arrays). If both compounds are of equal size, the compounds elements are compared in lexicographic order.

    • For resources, the values are compared using strcmp().

Parameters

lhs
The left-hand side operand for the comparison.
rhs
The right-hand side operand for the comparison.
epsilon
Maximum difference for floating point values to consider them as equal.

Returns

-1 if lhs < rhs , 0 if lhs == rhs , and +1 if lhs > rhs .

virtual Sint32 mi::​neuraylib::​IValue_factory::compare( const IValue_list* lhs, const IValue_list* rhs, Float64 epsilon = 0.0) const [pure virtual]

Compares two instances of mi::neuraylib::IValue_list. The comparison operator for instances of mi::neuraylib::IValue_list is defined as follows:

  • If lhs or rhs is NULL, the result is the lexicographic comparison of the pointer addresses themselves.

  • Next, the list sizes are compared using operator< () .

  • Next, the lists are traversed by increasing index and the names are compared using strcmp().

  • Finally, the list elements are enumerated by increasing index and the values are compared.

Parameters

lhs
The left-hand side operand for the comparison.
rhs
The right-hand side operand for the comparison.
epsilon
Maximum difference for floating point values to consider them as equal.

Returns

-1 if lhs < rhs , 0 if lhs == rhs , and +1 if lhs > rhs .

virtual IValue* mi::​neuraylib::​IValue_factory::create( const IType* type) const [pure virtual]

Creates a default-constructed value of the given type.

template< class T>

T* mi::​neuraylib::​IValue_factory::create( const IType* type) const [inline]

Creates a default-constructed value of the given type.

virtual IValue* mi::​neuraylib::​IValue_factory::create( const IAnnotation* annotation) const [pure virtual]

Creates a value observing the range of an "::anno::soft_range()" or an "::anno::hard_range()" annotation. The type of the value is determined by the parameter types of the annotation.

template< class T>

T* mi::​neuraylib::​IValue_factory::create( const IAnnotation* annotation) const [inline]

Creates a value observing the range of an "::anno::soft_range()" or an "::anno::hard_range()" annotation. The type of the value is determined by the parameter types of the annotation.

virtual IValue* mi::​neuraylib::​IValue_factory::create( const IType* type, const IAnnotation_block* annotation_block) const [pure virtual]

Creates a value observing a potentially present range annotation. This method is a convenience wrapper around the other two (non-template) overloads.

If annotation_block contains an "::anno::soft_range()" or an "::anno::hard_range()" annotation, then this method calls the annotation-based overload with that annotation (where "::anno::soft_range()" has priority over "::anno::hard_range()"). Otherwise, it calls the type-based overload with the given value type.

template< class T>

T* mi::​neuraylib::​IValue_factory::create( const IType* type, const IAnnotation_block* annotation_block) const [inline]

Creates a value observing a potentially present range annotation. This method is a convenience wrapper around the other two (template) overloads.

If annotation_block contains an "::anno::soft_range()" or an "::anno::hard_range()" annotation, then this method calls the annotation-based overload with that annotation (where "::anno::soft_range()" has priority over "::anno::hard_range()"). Otherwise, it calls the type-based overload with the given value type.

virtual IValue_array* mi::​neuraylib::​IValue_factory::create_array( const IType_array* type) const [pure virtual]

Creates a new value of type array, or returns NULL in case of errors.

virtual IValue_bool* mi::​neuraylib::​IValue_factory::create_bool( bool value = false) const [pure virtual]

Creates a new value of type boolean.

virtual IValue_bsdf_measurement* mi::​neuraylib::​IValue_factory::create_bsdf_measurement( const char* value) const [pure virtual]

Creates a new BSDF measurement value, or returns NULL in case of errors.

virtual IValue_color* mi::​neuraylib::​IValue_factory::create_color( Float32 red = 0.0f, Float32 green = 0.0f, Float32 blue = 0.0f) const [pure virtual]

Creates a new value of type color.

virtual IValue_double* mi::​neuraylib::​IValue_factory::create_double( Float64 value = 0.0) const [pure virtual]

Creates a new value of type double.

virtual IValue_enum* mi::​neuraylib::​IValue_factory::create_enum( const IType_enum* type, Size index = 0) const [pure virtual]

Creates a new value of type enum, or returns NULL in case of errors.

virtual IValue_float* mi::​neuraylib::​IValue_factory::create_float( Float32 value = 0.0f) const [pure virtual]

Creates a new value of type float.

virtual IValue_int* mi::​neuraylib::​IValue_factory::create_int( Sint32 value = 0) const [pure virtual]

Creates a new value of type integer.

virtual IValue_invalid_df* mi::​neuraylib::​IValue_factory::create_invalid_df( const IType_reference* type) const [pure virtual]

Creates a new invalid distribution function value.

virtual IValue_light_profile* mi::​neuraylib::​IValue_factory::create_light_profile( const char* value) const [pure virtual]

Creates a new light profile value, or returns NULL in case of errors.

virtual IValue_matrix* mi::​neuraylib::​IValue_factory::create_matrix( const IType_matrix* type) const [pure virtual]

Creates a new value of type matrix, or returns NULL in case of errors.

virtual IValue_string* mi::​neuraylib::​IValue_factory::create_string( const char* value = "") const [pure virtual]

Creates a new value of type string.

Parameters

value
The value NULL is handled like the empty string.
virtual IValue_struct* mi::​neuraylib::​IValue_factory::create_struct( const IType_struct* type) const [pure virtual]

Creates a new value of type struct, or returns NULL in case of errors.

virtual IValue_texture* mi::​neuraylib::​IValue_factory::create_texture( const IType_texture* type, const char* value) const [pure virtual]

Creates a new texture value, or returns NULL in case of errors.

virtual IValue_list* mi::​neuraylib::​IValue_factory::create_value_list() const [pure virtual]

Creates a new value list.

virtual IValue_vector* mi::​neuraylib::​IValue_factory::create_vector( const IType_vector* type) const [pure virtual]

Creates a new value of type vector, or returns NULL in case of errors.

virtual const IString* mi::​neuraylib::​IValue_factory::dump( const IValue* value, const char* name, Size depth = 0) const [pure virtual]

Returns a textual representation of a value. The textual representation is of the form "type name = value" if name is not NULL, and of the form "value" if name is NULL. The representation of the value might contain line breaks, for example for structures, enums, and arrays. Subsequent lines have a suitable indentation. The assumed indentation level of the first line is specified by depth.

Note:

The exact format of the textual representation is unspecified and might change in future releases. The textual representation is primarily meant as a debugging aid. Do not base application logic on it.

virtual const IString* mi::​neuraylib::​IValue_factory::dump( const IValue_list* list, const char* name, Size depth = 0) const [pure virtual]

Returns a textual representation of a value list. The representation of the value list will contain line breaks. Subsequent lines have a suitable indentation. The assumed indentation level of the first line is specified by depth.

Note:

The exact format of the textual representation is unspecified and might change in future releases. The textual representation is primarily meant as a debugging aid. Do not base application logic on it.

virtual IType_factory* mi::​neuraylib::​IValue_factory::get_type_factory() const [pure virtual]

Returns the type factory associated with this value factory.