neuray API Programmer's Manual

mi::IPointer Class Reference

[Simple Types]

Description

This interface represents mutable pointers. Mutable pointers in the sense of this interface are mutable interface pointers, not void* pointers.

Pointers are either typed or untyped. Typed pointers enforce the target to be of a certain type derived from mi::IData. The type name of a typed mutable pointer is "Pointer<", followed by the type name of the target, and finally ">", e.g., "Pointer<Sint32>" for a mutable pointer to an instance of mi::ISint32.

Untyped pointers simply store a mutable pointer of type mi::base::IInterface. The type name of an untyped mutable pointer is "Pointer<Interface>".

The additional level of indirection can be used to use mutable interface pointers with data collections while maintaining const correctness. E.g., the getters of mi::IData_collection, mi::IArray, mi::IDynamic_array, and mi::IMap return const interface pointers if the instance itself is const. If you want to retrieve a mutable interface pointer from such a collection you have to wrap it in an instance of mi::IPointer before you store it. When you retrieve it from the const collection, you can call get_pointer() to obtain the wrapped mutable interface pointer.

See also:

mi::IConst_pointer.

Public Member Functions

virtual base::​IInterfaceget_pointer() const =0
Returns the pointer.
template< class T>T* get_pointer() const
Returns the pointer. More...
virtual Sint32 set_pointer( base::​IInterface* pointer) =0
Sets the pointer. More...

Member Functions

virtual base::​IInterface* mi::​IPointer::get_pointer() const [pure virtual]

Returns the pointer.

template< class T>

T* mi::​IPointer::get_pointer() const [inline]

Returns the pointer. 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::​IPointer::set_pointer( base::​IInterface* pointer) [pure virtual]

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

Returns

  • 0: Success.
  • -1: pointer has the wrong type.