mi::neuraylib::IType_factory Class Reference
[MDL type system]
Description
The interface for creating types. A type factory can be obtained from mi::neuraylib::IMdl_factory::create_type_factory().
See also:
mi::neuraylib::IValue_factory, mi::neuraylib::IExpression_factory
Creation of types and type lists
- virtual const IType_alias* create_alias( const IType* type, Uint32 modifiers, const char* symbol) const =0
- Creates a new instance of the type alias.
- virtual const IType_bool* create_bool() const =0
- Creates a new instance of the type boolean.
- virtual const IType_bsdf* create_bsdf() const =0
- Creates a new instance of the type bsdf.
- virtual const IType_bsdf_measurement* create_bsdf_measurement() const =0
- Creates a new instance of the type bsdf_measurement.
- virtual const IType_color* create_color() const =0
- Creates a new instance of the type color.
- virtual const IType_array* create_deferred_sized_array( const IType* element_type, const char* size) const =0
- Creates a new instance of a deferred-sized array type.
- virtual const IType_double* create_double() const =0
- Creates a new instance of the double type.
- virtual const IType_edf* create_edf() const =0
- Creates a new instance of the type edf.
- virtual const IType_enum* create_enum( const char* symbol) const =0
- Returns a registered enum type, or NULL if symbol is invalid or unknown.
- virtual const IType_float* create_float() const =0
- Creates a new instance of the float type.
- virtual const IType_hair_bsdf* create_hair_bsdf() const =0
- Creates a new instance of the type hair_bsdf.
- virtual const IType_array* create_immediate_sized_array( const IType* element_type, Size size) const =0
- Creates a new instance of an immediate-sized array type.
- virtual const IType_int* create_int() const =0
- Creates a new instance of the type int.
- virtual const IType_light_profile* create_light_profile() const =0
- Creates a new instance of the type light_profile.
- virtual const IType_matrix* create_matrix( const IType_vector* column_type, Size columns) const =0
- Creates a new instance of a matrix type. More...
- virtual const IType_string* create_string() const =0
- Creates a new instance of the string type.
- virtual const IType_struct* create_struct( const char* symbol) const =0
- Returns a registered struct type, or NULL if symbol is invalid or unknown.
- virtual const IType_texture* create_texture( IType_texture::Shape shape) const =0
- Creates a new instance of the type texture.
- virtual IType_list* create_type_list() const =0
- Creates a new type map.
- virtual const IType_vdf* create_vdf() const =0
- Creates a new instance of the type vdf.
- virtual const IType_vector* create_vector( const IType_atomic* element_type, Size size) const =0
- Creates a new instance of a vector type. More...
- virtual const IType_enum* get_predefined_enum( IType_enum::Predefined_id id) const =0
- Returns a registered enum type, or NULL if id is unknown.
- virtual const IType_struct* get_predefined_struct( IType_struct::Predefined_id id) const =0
- Returns a registered struct type, or NULL if id is unknown.
Cloning of type lists
- virtual IType_list* clone( const IType_list* type_list) const =0
- Clones the given type list. More...
Comparison of types and type lists
- virtual Sint32 compare( const IType* lhs, const IType* rhs) const =0
- Compares two instances of mi::neuraylib::IType. More...
- virtual Sint32 compare( const IType_list* lhs, const IType_list* rhs) const =0
- Compares two instances of mi::neuraylib::IType_list. More...
- virtual Sint32 is_compatible( const IType* src, const IType* dst) const =0
- Checks, if two instances of mi::neuraylib::IType are compatible, meaning that src can be casted to dst. More...
Dumping of types and type lists
- virtual const IString* dump( const IType* type, Size depth = 0) const =0
- Returns a textual representation of a type. More...
- virtual const IString* dump( const IType_list* list, Size depth = 0) const =0
- Returns a textual representation of a type list. More...
Member Functions
- virtual IType_list* mi::neuraylib::IType_factory::clone( const IType_list* type_list) const [pure virtual]
-
Clones the given type list.
Note:There is no method clone a type itself. Types themselves are always const and there is no scenario where cloning of a type makes sense.
- virtual Sint32 mi::neuraylib::IType_factory::compare( const IType* lhs, const IType* rhs) const [pure virtual]
-
Compares two instances of mi::neuraylib::IType. The comparison operator for instances of mi::neuraylib::IType is defined as follows:
-
If lhs or rhs is NULL, the result is the lexicographic comparison of the pointer addresses themselves.
-
Otherwise, the kind of the types are compared. If they are different, the result is determined by operator< on the mi::neuraylib::IType::Kind values.
-
Finally, specific types are compared as follows:
-
mi::neuraylib::IType_enum and mi::neuraylib::IType_struct: The result is determined by strcmp() on the corresponding symbol names.
-
mi::neuraylib::IType_vector, mi::neuraylib::IType_matrix, mi::neuraylib::IType_array: If the element types are different, they determine the result of the comparison. If the element types are identical the number of compound elements determines the result.
-
mi::neuraylib::IType_alias: If the modifiers are different, they determine the result of the comparison. If the modifiers are identical, the aliased types determine the result.
-
mi::neuraylib::IType_texture: The result is determined by a comparison of the corresponding shapes.
-
All other pairs of (the same kind of) types are considered equal.
-
Parameters
- lhs
- The left-hand side operand for the comparison.
- rhs
- The right-hand side operand for the comparison.
Returns
-1 if lhs < rhs , 0 if lhs == rhs , and +1 if lhs > rhs .
-
- virtual Sint32 mi::neuraylib::IType_factory::compare( const IType_list* lhs, const IType_list* rhs) const [pure virtual]
-
Compares two instances of mi::neuraylib::IType_list. The comparison operator for instances of mi::neuraylib::IType_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 types are compared.
Parameters
- lhs
- The left-hand side operand for the comparison.
- rhs
- The right-hand side operand for the comparison.
Returns
-1 if lhs < rhs , 0 if lhs == rhs , and +1 if lhs > rhs .
-
- virtual const IType_alias* mi::neuraylib::IType_factory::create_alias( const IType* type, Uint32 modifiers, const char* symbol) const [pure virtual]
-
Creates a new instance of the type alias.
- virtual const IType_bool* mi::neuraylib::IType_factory::create_bool() const [pure virtual]
-
Creates a new instance of the type boolean.
- virtual const IType_bsdf* mi::neuraylib::IType_factory::create_bsdf() const [pure virtual]
-
Creates a new instance of the type bsdf.
- virtual const IType_bsdf_measurement* mi::neuraylib::IType_factory::create_bsdf_measurement() const [pure virtual]
-
Creates a new instance of the type bsdf_measurement.
- virtual const IType_color* mi::neuraylib::IType_factory::create_color() const [pure virtual]
-
Creates a new instance of the type color.
- virtual const IType_array* mi::neuraylib::IType_factory::create_deferred_sized_array( const IType* element_type, const char* size) const [pure virtual]
-
Creates a new instance of a deferred-sized array type.
- virtual const IType_double* mi::neuraylib::IType_factory::create_double() const [pure virtual]
-
Creates a new instance of the double type.
- virtual const IType_edf* mi::neuraylib::IType_factory::create_edf() const [pure virtual]
-
Creates a new instance of the type edf.
- virtual const IType_enum* mi::neuraylib::IType_factory::create_enum( const char* symbol) const [pure virtual]
-
Returns a registered enum type, or NULL if symbol is invalid or unknown.
- virtual const IType_float* mi::neuraylib::IType_factory::create_float() const [pure virtual]
-
Creates a new instance of the float type.
- virtual const IType_hair_bsdf* mi::neuraylib::IType_factory::create_hair_bsdf() const [pure virtual]
-
Creates a new instance of the type hair_bsdf.
- virtual const IType_array* mi::neuraylib::IType_factory::create_immediate_sized_array( const IType* element_type, Size size) const [pure virtual]
-
Creates a new instance of an immediate-sized array type.
- virtual const IType_int* mi::neuraylib::IType_factory::create_int() const [pure virtual]
-
Creates a new instance of the type int.
- virtual const IType_light_profile* mi::neuraylib::IType_factory::create_light_profile() const [pure virtual]
-
Creates a new instance of the type light_profile.
- virtual const IType_matrix* mi::neuraylib::IType_factory::create_matrix( const IType_vector* column_type, Size columns) const [pure virtual]
-
Creates a new instance of a matrix type.
Parameters
- column_type
- The column type needs to be a vector of either mi::neuraylib::IType_float or mi::neuraylib::IType_double.
- columns
- The number of columns, either 2, 3, or 4.
Returns
The corresponding matrix type, or NULL in case of errors.
- virtual const IType_string* mi::neuraylib::IType_factory::create_string() const [pure virtual]
-
Creates a new instance of the string type.
- virtual const IType_struct* mi::neuraylib::IType_factory::create_struct( const char* symbol) const [pure virtual]
-
Returns a registered struct type, or NULL if symbol is invalid or unknown.
- virtual const IType_texture* mi::neuraylib::IType_factory::create_texture( IType_texture::Shape shape) const [pure virtual]
-
Creates a new instance of the type texture.
- virtual IType_list* mi::neuraylib::IType_factory::create_type_list() const [pure virtual]
-
Creates a new type map.
- virtual const IType_vdf* mi::neuraylib::IType_factory::create_vdf() const [pure virtual]
-
Creates a new instance of the type vdf.
- virtual const IType_vector* mi::neuraylib::IType_factory::create_vector( const IType_atomic* element_type, Size size) const [pure virtual]
-
Creates a new instance of a vector type.
Parameters
- element_type
- The element type needs to be either mi::neuraylib::IType_bool, mi::neuraylib::IType_int, mi::neuraylib::IType_float, or mi::neuraylib::IType_double.
- size
- The number of elements, either 2, 3, or 4.
Returns
The corresponding vector type, or NULL in case of errors.
- virtual const IString* mi::neuraylib::IType_factory::dump( const IType* type, Size depth = 0) const [pure virtual]
-
Returns a textual representation of a type. The representation of the type might contain line breaks, for example for structures and enums. 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::IType_factory::dump( const IType_list* list, Size depth = 0) const [pure virtual]
-
Returns a textual representation of a type list. The representation of the type 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 const IType_enum* mi::neuraylib::IType_factory::get_predefined_enum( IType_enum::Predefined_id id) const [pure virtual]
-
Returns a registered enum type, or NULL if id is unknown.
- virtual const IType_struct* mi::neuraylib::IType_factory::get_predefined_struct( IType_struct::Predefined_id id) const [pure virtual]
-
Returns a registered struct type, or NULL if id is unknown.
- virtual Sint32 mi::neuraylib::IType_factory::is_compatible( const IType* src, const IType* dst) const [pure virtual]
-
Checks, if two instances of mi::neuraylib::IType are compatible, meaning that src can be casted to dst. src is compatible with and therefore can be casted to dst, if
-
src and dst are of identical type (see mi::neuraylib::IType_factory::compare()).
-
src and dst are of type mi::neuraylib::IType_struct, have the same number of fields and all fields are pairwise compatible. The names of the fields do not matter, only their order.
-
src and dst are of type mi::neuraylib::IType_enum and both enumeration types have the same set of numerical enumeration values. The names of the enumeration values, their order, or whether multiple enumeration value names share the same numerical value do not matter.
-
src and dst are of type mi::neuraylib::IType_array, both arrays are either immediated-sized or deferred-sized arrays, have the same size, and their element types are compatible.
Parameters
- src
- The source type.
- dst
- the target type to which src is intended to be compatible.
Returns
- 0 if src can be casted to dst, but src and dst are not of identical type.
- 1 if src and dst are of identical type.
- -1 if src cannot be casted to dst.
-