7#ifndef MI_NEURAYLIB_DEFINITION_WRAPPER_H
8#define MI_NEURAYLIB_DEFINITION_WRAPPER_H
255 if( !ptr_iscene_element)
257 T* ptr_T =
static_cast<T*
>( ptr_iscene_element->
get_interface(
typename T::IID()));
279 const std::string&
get_name()
const;
304 m_type = m_access ? m_access->get_element_type() :
static_cast<Element_type>( 0);
309 return m_access.is_valid_interface();
318 return m_access->is_valid( context);
331 return m_access->get_mdl_name();
339 return m_access->get_module();
347 return m_access->is_exported();
355 return m_access->is_declarative();
363 return m_access->is_material();
371 return m_access->get_parameter_count();
379 return m_access->get_parameter_name( index);
387 return m_access->get_parameter_index( name);
395 return m_access->get_parameter_types();
403 return m_access->get_return_type();
411 return m_access->get_thumbnail();
419 return m_access->get_defaults();
434 if( !default_constant)
438 return result == 0 ? 0 : -5;
453 if( !default_constant)
457 return result == 0 ? 0 : -5;
465 return m_access->get_annotations();
473 return m_access->get_parameter_annotations();
481 return m_access->get_return_annotations();
489 return m_access->get_enable_if_conditions();
497 return m_access->get_enable_if_users( index);
503 return static_cast<Size>( ~0);
505 return m_access->get_enable_if_user( index, u_index);
515 return m_access->create_function_call( arguments, errors);
532 m_access->get_parameter_annotations());
535 m_mdl_factory->create_expression_factory( m_transaction.get()));
538 Size count = m_access->get_parameter_count();
539 for(
Size i = 0; i < count; ++i) {
540 const char* name = m_access->get_parameter_name( i);
545 parameter_annotations->get_annotation_block( name));
548 local_arguments->add_expression( name, expr.
get());
551 return m_access->create_function_call( local_arguments.
get(), errors);
556 m_transaction->retain();
557 return m_transaction.get();
562 m_mdl_factory->retain();
563 return m_mdl_factory.get();
569 return m_access.get();
Handle class template for interfaces, automatizing the lifetime control via reference counting.
Definition: handle.h:113
A wrapper around the interface for MDL function definitions.
Definition: definition_wrapper.h:44
const char * get_module() const
Returns the DB name of the corresponding module.
Definition: definition_wrapper.h:334
Sint32 get_default(Size index, T &value) const
Returns the default of a non-array parameter.
Definition: definition_wrapper.h:423
const IExpression_list * get_enable_if_conditions() const
Returns the enable_if conditions of all parameters.
Definition: definition_wrapper.h:484
Definition_wrapper(ITransaction *transaction, const char *name, IMdl_factory *mdl_factory)
Constructs an MDL definition wrapper for a fixed material or function definition.
Definition: definition_wrapper.h:294
const IExpression_list * get_defaults() const
Returns the defaults of all parameters.
Definition: definition_wrapper.h:414
const char * get_mdl_definition() const
Returns the MDL name of the material or function definition.
Definition: definition_wrapper.h:326
const IAnnotation_list * get_parameter_annotations() const
Returns the annotations of all parameters.
Definition: definition_wrapper.h:468
const IType * get_return_type() const
Returns the return type.
Definition: definition_wrapper.h:398
const IType_list * get_parameter_types() const
Returns the types of all parameters.
Definition: definition_wrapper.h:390
Size get_enable_if_user(Size index, Size u_index) const
Returns the index of a parameter whose enable_if condition might depend on the argument of the given ...
Definition: definition_wrapper.h:500
bool is_material() const
Indicates whether the definition represents a material.
Definition: definition_wrapper.h:358
bool is_exported() const
Indicates whether the material or function definition is exported by its module.
Definition: definition_wrapper.h:342
bool is_valid_definition(IMdl_execution_context *context) const
Indicates whether the material or function definition referenced by this definition wrapper matches a...
Definition: definition_wrapper.h:313
T * create_instance(const IExpression_list *arguments=0, Sint32 *errors=0) const
Creates an instance of the material or function definition.
Definition: definition_wrapper.h:252
IMdl_factory * get_mdl_factory() const
Get the MDL factory.
Definition: definition_wrapper.h:560
ITransaction * get_transaction() const
Get the transaction.
Definition: definition_wrapper.h:554
Element_type get_type() const
Indicates whether the definition wrapper acts on a material definition or on a function definition.
Definition: definition_wrapper.h:321
bool is_declarative() const
Indicates whether the material or function definition is declarative.
Definition: definition_wrapper.h:350
const char * get_parameter_name(Size index) const
Returns the name of the parameter at index.
Definition: definition_wrapper.h:374
Element_type get_element_type() const
Get the element type.
Definition: definition_wrapper.h:572
const IAnnotation_block * get_return_annotations() const
Returns the annotations of the return type.
Definition: definition_wrapper.h:476
Size get_enable_if_users(Size index) const
Returns the number of other parameters whose enable_if condition might depend on the argument of the ...
Definition: definition_wrapper.h:492
const std::string & get_name() const
Get the DB name of the MDL function or material definition.
Definition: definition_wrapper.h:577
const IFunction_definition * get_scene_element() const
Get the MDL function or material definition.
Definition: definition_wrapper.h:566
bool is_valid() const
Indicates whether the definition wrapper is in a valid state.
Definition: definition_wrapper.h:307
const IAnnotation_block * get_annotations() const
Returns the annotations for a material or function definition.
Definition: definition_wrapper.h:460
IFunction_call * create_instance(const IExpression_list *arguments=0, Sint32 *errors=0) const
Creates an instance of the material or function definition.
Definition: definition_wrapper.h:508
Size get_parameter_index(const char *name) const
Returns the index position of a parameter.
Definition: definition_wrapper.h:382
const char * get_thumbnail() const
Returns the resolved file name of the thumbnail image for this MDL definition.
Definition: definition_wrapper.h:406
Size get_parameter_count() const
Returns the number of parameters.
Definition: definition_wrapper.h:366
An annotation block is an array of annotations.
Definition: iexpression.h:575
An ordered collection of annotation blocks identified by name or index.
Definition: iexpression.h:603
A constant expression.
Definition: iexpression.h:96
An ordered collection of expressions identified by name or index.
Definition: iexpression.h:317
This interface represents a function call.
Definition: ifunction_call.h:52
This interface represents a function definition.
Definition: ifunction_definition.h:44
Semantics
All known semantics of functions definitions.
Definition: ifunction_definition.h:54
@ DS_INTRINSIC_DAG_ARRAY_LENGTH
The array length operator. See Array length operator.
Definition: ifunction_definition.h:393
@ DS_TERNARY
The ternary operator (conditional). See Ternary operator.
Definition: ifunction_definition.h:126
@ DS_CAST
The cast operator. See Cast operator.
Definition: ifunction_definition.h:81
@ DS_INTRINSIC_DAG_ARRAY_CONSTRUCTOR
The array constructor. See Array constructor.
Definition: ifunction_definition.h:391
@ DS_ARRAY_INDEX
The array index operator. See Array index operator.
Definition: ifunction_definition.h:89
@ DS_INTRINSIC_DAG_DECL_CAST
The decl_cast operator. See Decl_cast operator.
Definition: ifunction_definition.h:395
The execution context can be used to query status information like error and warning messages concern...
Definition: imdl_execution_context.h:131
Factory for various MDL interfaces and functions.
Definition: imdl_factory.h:53
Common base interface for all scene elements.
Definition: iscene_element.h:75
A transaction provides a consistent view on the database.
Definition: itransaction.h:82
virtual const base::IInterface * access(const char *name)=0
Retrieves an element from the database.
An ordered collection of types identified by name or index.
Definition: itype.h:646
The interface to MDL types.
Definition: itype.h:151
virtual const IInterface * get_interface(const Uuid &interface_id) const =0
Acquires a const interface from another.
Handle<Interface> make_handle_dup(Interface *iptr)
Converts passed-in interface pointer to a handle, without taking interface over.
Definition: handle.h:439
Handle<New_interface> get_interface() const
Returns a new handle for a possibly different interface type, similar to a dynamic cast,...
Definition: handle.h:353
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.
Uint64 Size
Unsigned integral type that is large enough to hold the size of all types.
Definition: types.h:112
signed int Sint32
32-bit signed integer.
Definition: types.h:46
#define mi_neuray_assert(expr)
If expr evaluates to true this macro shall have no effect.
Definition: assert.h:67
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:1254
Element_type
Distinguishes scene elements.
Definition: iscene_element.h:30
Smart-pointer handle class for interfaces, const and non-const version.
Expressions of the MDL type system.
Scene element Function_call.
Scene element Function_definition.
Scene element Material_instance.
API component that gives access to some MDL functionality.
Types of the MDL type system.
Values of the MDL type system.
Common namespace for APIs of NVIDIA Advanced Rendering Center GmbH.
Definition: example_derivatives.dox:5
Assertions and compile-time assertions.