neuray API Programmer's Manual

mi::IConst_pointer Class Reference

[Simple Types]

Description

This interface represents const pointers. Const pointers in the sense of this interface are const interface pointers, not const 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 const pointer is "Const_pointer<", followed by the type name of the target, and finally ">", e.g., "Const_pointer<Sint32>" for a const pointer to an instance of mi::ISint32.

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

The additional level of indirection can be used to use const interface pointers with data collections while maintaining const correctness. E.g., the setters of mi::IData_collection, mi::IArray, mi::IDynamic_array, and mi::IMap take mutable interface pointers. If you want to store a const interface pointer you have to wrap it in an instance of mi::IConst_pointer before using it with these interfaces.

See also:

mi::IPointer.

Public Member Functions

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

Member Functions

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

Returns the const pointer.

template< class T>

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

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

Sets the const 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.