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

The module builder allows to create new MDL modules. More...

#include <imdl_module_builder.h>

Inheritance diagram for mi::neuraylib::IMdl_module_builder:

Public Member Functions

virtual Sint32 add_variant (const char *name, const char *prototype_name, const IExpression_list *defaults, const IAnnotation_block *annotations, const IAnnotation_block *return_annotations, bool is_exported, IMdl_execution_context *context)=0
 Adds a variant to the module. More...
 
virtual Sint32 add_function (const char *name, const IExpression *body, const IExpression_list *temporaries, const IType_list *parameters, const IExpression_list *defaults, const IAnnotation_list *parameter_annotations, const IAnnotation_block *annotations, const IAnnotation_block *return_annotations, bool is_exported, IType::Modifier frequency_qualifier, IMdl_execution_context *context)=0
 Adds a material or function to the module. More...
 
virtual Sint32 add_annotation (const char *name, const IType_list *parameters, const IExpression_list *defaults, const IAnnotation_list *parameter_annotations, const IAnnotation_block *annotations, bool is_exported, IMdl_execution_context *context)=0
 Adds an annotation to the module. More...
 
virtual Sint32 add_enum_type (const char *name, const IExpression_list *enumerators, const IAnnotation_list *enumerator_annotations, const IAnnotation_block *annotations, bool is_exported, IMdl_execution_context *context)=0
 Adds an enum type to the module. More...
 
virtual Sint32 add_struct_type (const char *name, const IType_list *fields, const IExpression_list *field_defaults, const IAnnotation_list *field_annotations, const IAnnotation_block *annotations, bool is_exported, IMdl_execution_context *context)=0
 Adds a struct type to the module. More...
 
virtual Sint32 add_constant (const char *name, const IExpression *expr, const IAnnotation_block *annotations, bool is_exported, IMdl_execution_context *context)=0
 Adds a constant to the module. More...
 
virtual Sint32 set_module_annotations (const IAnnotation_block *annotations, IMdl_execution_context *context)=0
 Sets the annotations of the module itself. More...
 
virtual Sint32 remove_entity (const char *name, Size index, IMdl_execution_context *context)=0
 Removes a material, function, enum or struct type from the module. More...
 
virtual Sint32 clear_module (IMdl_execution_context *context)=0
 Clears the module, i.e., removes all declarations from the module. More...
 
virtual const IArrayanalyze_uniform (const IExpression *root_expr, bool root_expr_uniform, IMdl_execution_context *context)=0
 Analyzes which parameters need to be uniform. 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< 0x2357f2f8, ... >
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< 0x2357f2f8, ... >
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 module builder allows to create new MDL modules.

See also
mi::neuraylib::IMdl_factory::create_module_builder()

Member Function Documentation

 add_annotation()

virtual Sint32 mi::neuraylib::IMdl_module_builder::add_annotation ( const char *  name,
const IType_list parameters,
const IExpression_list defaults,
const IAnnotation_list parameter_annotations,
const IAnnotation_block annotations,
bool  is_exported,
IMdl_execution_context context 
)
pure virtual

Adds an annotation to the module.

Parameters
nameThe simple name of the annotation.
parametersTypes and names of the parameters. Can be NULL (treated like an empty parameter list).
defaultsDefault values. Can be NULL or incomplete. Feasible sub-expression kinds: constants, calls, and direct calls.
parameter_annotationsParameter annotations. Can be NULL or incomplete.
annotationsAnnotations of the annotation. Can be NULL.
is_exportedIndicates whether the annotation will have the 'export' keyword.
contextThe execution context can be used to pass options and to retrieve error and/or warning messages. Can be NULL.

 add_constant()

virtual Sint32 mi::neuraylib::IMdl_module_builder::add_constant ( const char *  name,
const IExpression expr,
const IAnnotation_block annotations,
bool  is_exported,
IMdl_execution_context context 
)
pure virtual

Adds a constant to the module.

Parameters
nameThe simple name of the constant.
exprThe value of the constant. Feasible sub-expression kinds: constants and direct calls.
annotationsAnnotations of the constant. Can be NULL.
is_exportedIndicates whether the constant will have the 'export' keyword.
contextThe execution context can be used to pass options and to retrieve error and/or warning messages. Can be NULL.

 add_enum_type()

virtual Sint32 mi::neuraylib::IMdl_module_builder::add_enum_type ( const char *  name,
const IExpression_list enumerators,
const IAnnotation_list enumerator_annotations,
const IAnnotation_block annotations,
bool  is_exported,
IMdl_execution_context context 
)
pure virtual

Adds an enum type to the module.

Note
Changing a particular enum type, i.e., removing it and re-adding it differently, is not supported.
Parameters
nameThe simple name of the enum type.
enumeratorsEnumerators of the enum type. Must not be empty. Feasible sub-expression kinds: constants and direct calls.
enumerator_annotationsEnumerator annotations. Can be NULL or incomplete.
annotationsAnnotations of the enum type. Can be NULL.
is_exportedIndicates whether the enum type will have the 'export' keyword.
contextThe execution context can be used to pass options and to retrieve error and/or warning messages. Can be NULL.

 add_function()

virtual Sint32 mi::neuraylib::IMdl_module_builder::add_function ( const char *  name,
const IExpression body,
const IExpression_list temporaries,
const IType_list parameters,
const IExpression_list defaults,
const IAnnotation_list parameter_annotations,
const IAnnotation_block annotations,
const IAnnotation_block return_annotations,
bool  is_exported,
IType::Modifier  frequency_qualifier,
IMdl_execution_context context 
)
pure virtual

Adds a material or function to the module.

Parameters
nameThe simple name of the material or function.
bodyThe body of the new material or function (a constant, direct call, or parameter reference). Feasible sub-expression kinds: constants, direct calls, parameter references, and temporary references.
temporariesTemporaries referenced by the body. Feasible sub-expression kinds: constants, direct calls, parameter references, and temporary references with smaller index. The names associated with the expressions in the expressions list are not relevant (but need to unique as usual). Can be NULL (treated like an empty expression list).
parametersTypes and names of the parameters. Can be NULL (treated like an empty parameter list).
defaultsDefault values. Can be NULL or incomplete. Feasible sub-expression kinds: constants, calls, and direct calls.
parameter_annotationsParameter annotations. Can be NULL or incomplete.
annotationsAnnotations of the material or function. Can be NULL.
return_annotationsReturn annotations of the function. Can be NULL for functions, must be NULL for materials.
is_exportedIndicates whether the material or function will have the 'export' keyword.
frequency_qualifierThe frequency qualifier for functions, or mi::neuraylib::IType::MK_NONE for materials.
contextThe execution context can be used to pass options and to retrieve error and/or warning messages. Can be NULL.

 add_struct_type()

virtual Sint32 mi::neuraylib::IMdl_module_builder::add_struct_type ( const char *  name,
const IType_list fields,
const IExpression_list field_defaults,
const IAnnotation_list field_annotations,
const IAnnotation_block annotations,
bool  is_exported,
IMdl_execution_context context 
)
pure virtual

Adds a struct type to the module.

Note
Changing a particular struct type, i.e., removing it and re-adding it differently, is not supported.
Parameters
nameThe simple name of the enum type.
fieldsFields of the struct type. Must not be empty.
field_defaultsDefaults of the struct fields. Can be NULL or incomplete. Feasible sub-expression kinds: constants and direct calls.
field_annotationsField annotations of the struct type. Can be NULL or incomplete.
annotationsAnnotations of the struct type. Can be NULL.
is_exportedIndicates whether the struct type will have the 'export' keyword.
contextThe execution context can be used to pass options and to retrieve error and/or warning messages. Can be NULL.

 add_variant()

virtual Sint32 mi::neuraylib::IMdl_module_builder::add_variant ( const char *  name,
const char *  prototype_name,
const IExpression_list defaults,
const IAnnotation_block annotations,
const IAnnotation_block return_annotations,
bool  is_exported,
IMdl_execution_context context 
)
pure virtual

Adds a variant to the module.

Parameters
nameThe simple name of the material or function variant.
prototype_nameThe DB name of the prototype of the new variant.
defaultsDefault values to set. If NULL, the defaults of the original material or function are used. Feasible sub-expression kinds: constants and calls.
annotationsAnnotations to set. If NULL, the annotations of the original material or function are used. Pass an empty block to remove all annotations.
return_annotationsReturn annotations to set. If NULL, the annotations of the original material or function are used. Pass an empty block to remove all annotations. Materials require NULL or an empty annotation block here.
is_exportedIndicates whether the variant will have the 'export' keyword.
contextThe execution context can be used to pass options and to retrieve error and/or warning messages. Can be NULL.
Returns
0 in case of success, or -1 in case of failure.

 analyze_uniform()

virtual const IArray * mi::neuraylib::IMdl_module_builder::analyze_uniform ( const IExpression root_expr,
bool  root_expr_uniform,
IMdl_execution_context context 
)
pure virtual

Analyzes which parameters need to be uniform.

Note that the method can fail if the graph to be analyzed is invalid and/or never uniform independent of uniform modifiers of parameter types.

root_expr_uniform is false root_expr_uniform is true Interpretation
failurefailureThe graph is invalid.
failuresuccessThis case is not possible.
successfailureThe graph is never uniform.
successsuccessThe graph is uniform if the parameters returned in the true case are made uniform.

If the graph should be uniform, and you cannot rule out invalid graphs, then you might want to invoke this method first with root_expr_uniform set to false to check for validity. If that method succeeds, you can then call it again with root_expr_uniform set to true to obtain the constraints on the parameters.

Parameters
root_exprRoot expression of the graph, i.e., the body of the new material or function. Feasible sub-expression kinds: constants, direct calls, and parameter references.
root_expr_uniformIndicates whether the root expression should be uniform.
contextThe execution context can be used to pass options and to retrieve error and/or warning messages. Can be NULL.
Returns
Returns an array of boolean values indicating which parameters need to be uniform (or NULL in case of errors). The array indices match the indices of the parameter references. The array might be shorter than expected if trailing parameters are not referenced by root_expr.

 clear_module()

virtual Sint32 mi::neuraylib::IMdl_module_builder::clear_module ( IMdl_execution_context context)
pure virtual

Clears the module, i.e., removes all declarations from the module.

 remove_entity()

virtual Sint32 mi::neuraylib::IMdl_module_builder::remove_entity ( const char *  name,
Size  index,
IMdl_execution_context context 
)
pure virtual

Removes a material, function, enum or struct type from the module.

Parameters
nameThe simple name of material, function, enum or struct type to be removed.
indexThe index of the function with the given name to be removed. Used to distinguish overloads of functions. Zero for materials, enum or struct types.
contextThe execution context can be used to pass options and to retrieve error and/or warning messages. Can be NULL.

 set_module_annotations()

virtual Sint32 mi::neuraylib::IMdl_module_builder::set_module_annotations ( const IAnnotation_block annotations,
IMdl_execution_context context 
)
pure virtual

Sets the annotations of the module itself.

Parameters
annotationsAnnotations of the module. Pass NULL to remove existing annotations.
contextThe execution context can be used to pass options and to retrieve error and/or warning messages. Can be NULL.