MDL SDK API nvidia_logo_transpbg.gif Up
mi::neuraylib::IType_factory Class Referenceabstract

The interface for creating types. More...

#include <itype.h>

Inheritance diagram for mi::neuraylib::IType_factory:

Public Member Functions

Creation of types and type lists
virtual const IType_aliascreate_alias (const IType *type, Uint32 modifiers, const char *symbol) const =0
 Creates a new instance of the type alias. More...
 
virtual const IType_boolcreate_bool () const =0
 Creates a new instance of the type boolean. More...
 
virtual const IType_intcreate_int () const =0
 Creates a new instance of the type int. More...
 
virtual const IType_enumcreate_enum (const char *symbol) const =0
 Returns a registered enum type, or NULL if symbol is invalid or unknown. More...
 
virtual const IType_floatcreate_float () const =0
 Creates a new instance of the float type. More...
 
virtual const IType_doublecreate_double () const =0
 Creates a new instance of the double type. More...
 
virtual const IType_stringcreate_string () const =0
 Creates a new instance of the string type. More...
 
virtual const IType_vectorcreate_vector (const IType_atomic *element_type, Size size) const =0
 Creates a new instance of a vector type. More...
 
virtual const IType_matrixcreate_matrix (const IType_vector *column_type, Size columns) const =0
 Creates a new instance of a matrix type. More...
 
virtual const IType_colorcreate_color () const =0
 Creates a new instance of the type color. More...
 
virtual const IType_arraycreate_immediate_sized_array (const IType *element_type, Size size) const =0
 Creates a new instance of an immediate-sized array type. More...
 
virtual const IType_arraycreate_deferred_sized_array (const IType *element_type, const char *size) const =0
 Creates a new instance of a deferred-sized array type. More...
 
virtual const IType_structcreate_struct (const char *symbol) const =0
 Returns a registered struct type, or NULL if symbol is invalid or unknown. More...
 
virtual const IType_texturecreate_texture (IType_texture::Shape shape) const =0
 Creates a new instance of the type texture. More...
 
virtual const IType_light_profilecreate_light_profile () const =0
 Creates a new instance of the type light_profile. More...
 
virtual const IType_bsdf_measurementcreate_bsdf_measurement () const =0
 Creates a new instance of the type bsdf_measurement. More...
 
virtual const IType_bsdfcreate_bsdf () const =0
 Creates a new instance of the type bsdf. More...
 
virtual const IType_hair_bsdfcreate_hair_bsdf () const =0
 Creates a new instance of the type hair_bsdf. More...
 
virtual const IType_edfcreate_edf () const =0
 Creates a new instance of the type edf. More...
 
virtual const IType_vdfcreate_vdf () const =0
 Creates a new instance of the type vdf. More...
 
virtual IType_listcreate_type_list () const =0
 Creates a new type map. More...
 
virtual const IType_enumget_predefined_enum (IType_enum::Predefined_id id) const =0
 Returns a registered enum type, or NULL if id is unknown. More...
 
virtual const IType_structget_predefined_struct (IType_struct::Predefined_id id) const =0
 Returns a registered struct type, or NULL if id is unknown. More...
 
virtual const ITypecreate_from_mdl_type_name (const char *name) const =0
 Creates a type based on its MDL type name. More...
 
template<class T>
const T * create_from_mdl_type_name (const char *name) const
 Creates a type based on its MDL type name. More...
 
Cloning of type lists
virtual IType_listclone (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 IStringdump (const IType *type, Size depth=0) const =0
 Returns a textual representation of a type. More...
 
virtual const IStringdump (const IType_list *list, Size depth=0) const =0
 Returns a textual representation of a type list. More...
 
Miscellaneous methods
virtual const IStringget_mdl_module_name (const IType *type) const =0
 Returns the MDL module name of the module which defines type. More...
 
virtual const IStringget_mdl_type_name (const IType *type) const =0
 Returns the MDL type name of a type. More...
 
- Public Member Functions inherited from mi::base::IInterface
virtual Uint32 retain () const =0
 Increments the reference count. More...
 
virtual Uint32 release () const =0
 Decrements the reference count. More...
 
virtual const IInterfaceget_interface (const Uuid &interface_id) const =0
 Acquires a const interface from another. More...
 
template<class T>
const T * get_interface () const
 Acquires a const interface from another. More...
 
virtual IInterfaceget_interface (const Uuid &interface_id)=0
 Acquires a mutable interface from another. More...
 
template<class T>
T * get_interface ()
 Acquires a mutable interface from another. More...
 
virtual Uuid get_iid () const =0
 Returns the interface ID of the most derived interface. More...
 

Additional Inherited Members

- Public Types inherited from mi::base::Interface_declare< 0x353803c0, ... >
typedef Interface_declare< id1, ... > Self
 Own type. More...
 
typedef Uuid_t< id1, ... > IID
 Declares the interface ID (IID) of this interface. More...
 
- Public Types inherited from mi::base::IInterface
typedef Uuid_t<0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0> IID
 Declares the interface ID (IID) of this interface. More...
 
- Static Public Member Functions inherited from mi::base::Interface_declare< 0x353803c0, ... >
static bool compare_iid (const Uuid &iid)
 Compares the interface ID iid against the interface ID of this interface and of its ancestors. More...
 
- Static Public Member Functions inherited from mi::base::IInterface
static bool compare_iid (const Uuid &iid)
 Compares the interface ID iid against the interface ID of this interface. More...
 

Detailed 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

Member Function Documentation

 clone()

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.

 compare() [1/2]

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:
Parameters
lhsThe left-hand side operand for the comparison.
rhsThe right-hand side operand for the comparison.
Returns
-1 if lhs < rhs, 0 if lhs == rhs, and +1 if lhs > rhs.

 compare() [2/2]

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
lhsThe left-hand side operand for the comparison.
rhsThe right-hand side operand for the comparison.
Returns
-1 if lhs < rhs, 0 if lhs == rhs, and +1 if lhs > rhs.

 create_alias()

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.

 create_bool()

virtual const IType_bool * mi::neuraylib::IType_factory::create_bool ( ) const
pure virtual

Creates a new instance of the type boolean.

 create_bsdf()

virtual const IType_bsdf * mi::neuraylib::IType_factory::create_bsdf ( ) const
pure virtual

Creates a new instance of the type bsdf.

 create_bsdf_measurement()

virtual const IType_bsdf_measurement * mi::neuraylib::IType_factory::create_bsdf_measurement ( ) const
pure virtual

Creates a new instance of the type bsdf_measurement.

 create_color()

virtual const IType_color * mi::neuraylib::IType_factory::create_color ( ) const
pure virtual

Creates a new instance of the type color.

 create_deferred_sized_array()

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.

Parameters
element_typeThe type of the array elements.
sizeThe size symbol, e.g., "N". The actual value of the size symbol does not matter in most cases, e.g., for arguments. It does matter when constructing new functions and materials using the module builder (see mi::neuraylib::IMdl_module_builder).
Returns
The corresponding array type, or NULL in case of errors.

 create_double()

virtual const IType_double * mi::neuraylib::IType_factory::create_double ( ) const
pure virtual

Creates a new instance of the double type.

 create_edf()

virtual const IType_edf * mi::neuraylib::IType_factory::create_edf ( ) const
pure virtual

Creates a new instance of the type edf.

 create_enum()

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.

 create_float()

virtual const IType_float * mi::neuraylib::IType_factory::create_float ( ) const
pure virtual

Creates a new instance of the float type.

 create_from_mdl_type_name() [1/2]

template<class T>
const T * mi::neuraylib::IType_factory::create_from_mdl_type_name ( const char *  name) const
inline

Creates a type based on its MDL type name.

Contrary to MDL source code, whitespace is meaningful. In other words, only the strings produced by get_mdl_type_name() are supported here. For enums and structs, the corresponding module must have been loaded, such that these types are registered.

Note
Named aliases are not yet supported.

 create_from_mdl_type_name() [2/2]

virtual const IType * mi::neuraylib::IType_factory::create_from_mdl_type_name ( const char *  name) const
pure virtual

Creates a type based on its MDL type name.

Contrary to MDL source code, whitespace is meaningful. In other words, only the strings produced by get_mdl_type_name() are supported here. For enums and structs, the corresponding module must have been loaded, such that these types are registered.

Note
Named aliases are not yet supported.

 create_hair_bsdf()

virtual const IType_hair_bsdf * mi::neuraylib::IType_factory::create_hair_bsdf ( ) const
pure virtual

Creates a new instance of the type hair_bsdf.

 create_immediate_sized_array()

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.

 create_int()

virtual const IType_int * mi::neuraylib::IType_factory::create_int ( ) const
pure virtual

Creates a new instance of the type int.

 create_light_profile()

virtual const IType_light_profile * mi::neuraylib::IType_factory::create_light_profile ( ) const
pure virtual

Creates a new instance of the type light_profile.

 create_matrix()

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_typeThe column type needs to be a vector of either mi::neuraylib::IType_float or mi::neuraylib::IType_double.
columnsThe number of columns, either 2, 3, or 4.
Returns
The corresponding matrix type, or NULL in case of errors.

 create_string()

virtual const IType_string * mi::neuraylib::IType_factory::create_string ( ) const
pure virtual

Creates a new instance of the string type.

 create_struct()

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.

 create_texture()

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.

 create_type_list()

virtual IType_list * mi::neuraylib::IType_factory::create_type_list ( ) const
pure virtual

Creates a new type map.

 create_vdf()

virtual const IType_vdf * mi::neuraylib::IType_factory::create_vdf ( ) const
pure virtual

Creates a new instance of the type vdf.

 create_vector()

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_typeThe element type needs to be either mi::neuraylib::IType_bool, mi::neuraylib::IType_int, mi::neuraylib::IType_float, or mi::neuraylib::IType_double.
sizeThe number of elements, either 2, 3, or 4.
Returns
The corresponding vector type, or NULL in case of errors.

 dump() [1/2]

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.

 dump() [2/2]

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.

 get_mdl_module_name()

virtual const IString * mi::neuraylib::IType_factory::get_mdl_module_name ( const IType type) const
pure virtual

Returns the MDL module name of the module which defines type.

The module name is derived from the symbol of enum, struct, and alias types. For array types, the corresponding element type is considered. Frequency modifiers of alias types are ignored. Returns the name of the ::<builtins> module for all other types.

Use mi::neuraylib::IMdl_factory::get_db_module_name() to compute the corresponding DB name.

 get_mdl_type_name()

virtual const IString * mi::neuraylib::IType_factory::get_mdl_type_name ( const IType type) const
pure virtual

Returns the MDL type name of a type.

The MDL type name is:

  • for array types: the MDL type name of the element type followed by square brackets around the array size (for fixed-sized arrays) or the array size symbol (for deferred-sized arrays). Note that no additional angle brackets are used for deferred-sized arrays.
  • for enum and struct types: the corresponding symbol. This string is fully-qualified, except for enum and structs types from the ::<builtins> module, e.g., "material" or "intensity_mode".
  • for alias types: the MDL type name of the aliased type prefixed by "uniform " or "varying ". Note that named aliases are not yet supported.
  • for all other types: the corresponding reserved word from section 5.7 in [MDLLS].
See also
create_from_mdl_type_name()

 get_predefined_enum()

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.

 get_predefined_struct()

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.

 is_compatible()

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 immediate-sized or deferred-sized arrays, have the same size, and their element types are compatible.
Parameters
srcThe source type.
dstthe 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.