NVIDIA Iray API Home  Up
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
mi::IAttachable Class Referenceabstract

Attachables provide an alternative between a reference and another type. More...

Inheritance diagram for mi::IAttachable:
Inheritance graph
[legend]

Public Member Functions

virtual Sint32  set_reference (const base::IInterface *db_element)=0
  Sets the reference to db_element. More...
 
virtual Sint32  set_reference (const char *name)=0
  Sets the reference to the database element named name. More...
 
virtual const base::IInterface get_reference () const =0
  Returns the reference. More...
 
template<class T >
const T *  get_reference () const
  Returns the reference. More...
 
virtual base::IInterface get_reference ()=0
  Returns the reference. More...
 
template<class T >
T *  get_reference ()
  Returns the reference. More...
 
virtual const char *  get_reference_name () const =0
  Returns the name of the referenced element. More...
 
virtual const IData get_value () const =0
  Returns the value. More...
 
template<class T >
const T *  get_value () const
  Returns the value. More...
 
virtual IData get_value ()=0
  Returns the value. More...
 
template<class T >
T *  get_value ()
  Returns the value. More...
 

Additional Inherited Members

- Public Types inherited from mi::base::Interface_declare< 0x5e7a28b7, 0x38aa, 0x45ac, 0x98, 0x65, 0x97, 0xac, 0xcd, 0x81, 0xc4, 0x0e, IData_simple >
typedef Interface_declare< id1,
id2, id3, id4, id5, id6, id7,
id8, id9, id10, id11,
IData_simple
Self
  Own type. More...
 
typedef Uuid_t< id1, id2, id3,
id4, id5, id6, id7, id8, id9,
id10, id11 > 
IID
  Declares the interface ID (IID) of this interface. More...
 
- Static Public Member Functions inherited from mi::base::Interface_declare< 0x5e7a28b7, 0x38aa, 0x45ac, 0x98, 0x65, 0x97, 0xac, 0xcd, 0x81, 0xc4, 0x0e, IData_simple >
static bool  compare_iid (const Uuid &iid)
  Compares the interface ID iid against the interface ID of this interface and of its ancestors. More...
 

Detailed Description

Attachables provide an alternative between a reference and another type.

Attachables are used to specify arguments of MDL material instances or function calls. There are two different kinds of such arguments: mutable, but fixed values, and (mutable) return values of other MDL material instances or function calls. The latter are represented by a reference to that material instance or function call, the former are represented by an additional attribute value.

Attachables are used to represent these two alternatives: they can hold a reference to another DB element (similar to mi::IRef), or a value of any other type. The reference has precedence of the value. If the reference is set, it represents the attachable, if not, the value represents the attachable. These references are also called attachments.

The type name of an attachable is "Attachable<", followed by the type name of the value, and finally ">", e.g., "Attachable<Color>" for an attachable that allows to set a mutable, but fixed color, or a reference to an MDL material instance of a function call that returns a color.

If the attachable is an attribute, the value can be directly accessed by adding ".value" to the name of the attachable.

See Also
mi::neuraylib::IMdl_material_instance, mi::neuraylib::IMdl_function_call, mi::IRef

Member Function Documentation

virtual const base::IInterface* mi::IAttachable::get_reference ( ) const
pure virtual

Returns the reference.

template<class T >
const T* mi::IAttachable::get_reference ( ) const
inline

Returns the reference.

This templated member function is a wrapper of the non-template variant for the user's convenience. It eliminates the need to call mi::base::IInterface::get_interface(const Uuid&) on the returned pointer, since the return type already is a pointer to the type T specified as template parameter.

Template Parameters
T The requested interface type
virtual base::IInterface* mi::IAttachable::get_reference ( )
pure virtual

Returns the reference.

template<class T >
T* mi::IAttachable::get_reference ( )
inline

Returns the reference.

This templated member function is a wrapper of the non-template variant for the user's convenience. It eliminates the need to call mi::base::IInterface::get_interface(const Uuid&) on the returned pointer, since the return type already is a pointer to the type T specified as template parameter.

Template Parameters
T The requested interface type
virtual const char* mi::IAttachable::get_reference_name ( ) const
pure virtual

Returns the name of the referenced element.

virtual const IData* mi::IAttachable::get_value ( ) const
pure virtual

Returns the value.

template<class T >
const T* mi::IAttachable::get_value ( ) const
inline

Returns the value.

This templated member function is a wrapper of the non-template variant for the user's convenience. It eliminates the need to call mi::base::IInterface::get_interface(const Uuid &) on the returned pointer, since the return type already is a pointer to the type T specified as template parameter.

virtual IData* mi::IAttachable::get_value ( )
pure virtual

Returns the value.

template<class T >
T* mi::IAttachable::get_value ( )
inline

Returns the value.

This templated member function is a wrapper of the non-template variant for the user's convenience. It eliminates the need to call mi::base::IInterface::get_interface(const Uuid &) on the returned pointer, since the return type already is a pointer to the type T specified as template parameter.

virtual Sint32 mi::IAttachable::set_reference ( const base::IInterface db_element)
pure virtual

Sets the reference to db_element.

Note that a NULL pointer is a valid parameter value that clears the previously set reference. Subsequent get_reference() calls will return NULL then.

If a literal 0 is passed for db_element, the call is ambiguous. You need to explicitly cast the value to const IInterface* or const char*.

Note
This method might succeed even though the constructed attachable is considered ill-formed. This happens if an MDL function call with a varying return type is attached to a parameter that is marked as uniform. These kinds of mismatches will only be detected later and result in an invalid material instance or function call.
Returns
virtual Sint32 mi::IAttachable::set_reference ( const char *  name)
pure virtual

Sets the reference to the database element named name.

Note that a NULL pointer is a valid parameter value that clears the previously set reference. Subsequent get_reference() calls will return NULL then.

If a literal 0 is passed for name, the call is ambiguous. You need to explicitly cast the value to const IInterface* or const char*.

Note
This method might succeed even though the constructed attachable is considered ill-formed. This happens if an MDL function call with a varying return type is attached to a parameter that is marked as uniform. These kinds of mismatches will only be detected later and result in an invalid material instance or function call.
Returns