A temporary reference expression. More...
#include <iexpression.h>
Public Member Functions | |
virtual Size | get_index () const =0 |
Returns the index of the referenced temporary. More... | |
virtual void | set_index (Size index)=0 |
Sets the index of the referenced temporary. More... | |
Public Member Functions inherited from mi::neuraylib::IExpression | |
virtual Kind | get_kind () const =0 |
Returns the kind of this expression. More... | |
virtual const IType * | get_type () const =0 |
Returns the type of this expression. More... | |
template<class T> | |
const T * | get_type () const |
Returns the type of this expression. 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 IInterface * | get_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 IInterface * | get_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... | |
Static Public Attributes | |
static const Kind | s_kind = EK_TEMPORARY |
The kind of this subclass. More... | |
Additional Inherited Members | |
Public Types inherited from mi::base::Interface_declare< 0xd91f484b, ... > | |
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::neuraylib::IExpression | |
enum | Kind { EK_CONSTANT , EK_CALL , EK_PARAMETER , EK_DIRECT_CALL , EK_TEMPORARY , EK_FORCE_32_BIT = 0xffffffffU } |
The possible kinds of expressions. More... | |
Public Types inherited from mi::base::Interface_declare< 0x0f4a7542, ... > | |
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< 0xd91f484b, ... > | |
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::Interface_declare< 0x0f4a7542, ... > | |
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... | |
A temporary reference expression.
Temporary reference expressions are used to make the structure of DAGs (directed acyclic graphs) more explicit. Consider a diamond-shaped graph with four nodes A, B, C, and D. Node A references nodes B and C, and both nodes B and C reference node D.
When traversing this graph starting at node A, it could be important to realize when the node D is visited a second time (to avoid double work for node D, or to avoid misinterpreting the graph as a tree).
Note that in this example we use letters to identify the nodes. But expressions themselves do not have names. And the MDL SDK API does not guarantee identical pointer addresses for repeated accesses to the (logically) same object. For example, repeated calls of mi::neuraylib::IExpression_direct_call::get_arguments() followed by mi::neuraylib::IExpression_list::get_expression() result in different pointers, although logically the result is always the same (for the same input). Therefore, a different mechanism is needed to recognize nodes that can be visited several times in a traversal.
This is where temporary references come into play. In an expression graph for the example above, the nodes B and C do not point directly to node D, but to two temporary reference expressions, both with the same index. The node D can then be retrieved by passing that index to mi::neuraylib::IFunction_definition::get_temporary() or mi::neuraylib::ICompiled_material::get_temporary().
A common idiom is to traverse temporaries first, storing the result for each temporary, and to use them when encountering the corresponding temporary reference. Alternatively, one can traverse temporaries when encountered on-demand, store the result for each temporary, and reuse the result of the first encounter of a particular temporary on later encounters of that temporary.
Note that, despite the name mi::neuraylib::IExpression_temporary, expressions of this type are not the temporaries themselves, but references to temporaries. Temporaries can be nested, i.e., a temporary with index i might contain temporary references for other temporaries with indices up to i-1.
Temporary reference expressions appear in fields (and temporaries) of compiled materials, and in the bodies (and temporaries) of function and material definitions.
|
pure virtual |
Returns the index of the referenced temporary.
|
pure virtual |
Sets the index of the referenced temporary.
|
static |
The kind of this subclass.