neuray API Programmer's Manual

mi::IArray Class Reference

[Collections]

Description

This interface represents static arrays, i.e., arrays with a fixed number of elements. Arrays are either typed or untyped. Typed arrays enforce all elements to be of the same type. The elements of typed arrays have to be derived from mi::IData. The type name of a typed array is the type name of the element followed by "[", the size of the array (a non-negative integer), and finally "]", e.g., "Sint32[10]" for an array of 10 mi::Sint32 elements. The elements of a typed array are default-constructed.

Untyped arrays simply store pointers of type mi::base::IInterface. The type name of an untyped array is "Interface[" followed by the size of the array (a non-negative integer) and finally "]. The elements of an untyped array are default-constructed as instance of mi::IVoid.

The keys of an array (see mi::IData_collection) are the indices converted to strings.

See also:

mi::IDynamic_array

Public Member Functions

virtual bool  empty() const =0
Checks whether the array is empty. More...
virtual const base::​IInterfaceget_element( Size index) const =0
Returns the index -th element of the array. More...
template< class T>const T* get_element( Size index) const
Returns the index -th element of the array. More...
virtual base::​IInterfaceget_element( Size index) =0
Returns the index -th element of the array. More...
template< class T>T* get_element( Size index)
Returns the index -th element of the array. More...
virtual Size get_length() const =0
Returns the size of the array. More...
virtual Sint32 set_element( Size index, base::​IInterface* element) =0
Sets the index -th element of the array. More...

Member Functions

virtual bool mi::​IArray::empty() const [pure virtual]

Checks whether the array is empty. Equivalent to get_length() == 0.

virtual const base::​IInterface* mi::​IArray::get_element( Size index) const [pure virtual]

Returns the index -th element of the array.

Parameters

index
The index of the requested element.

Returns

The requested element, or NULL if index is equal to or larger than the size of the array.

template< class T>

const T* mi::​IArray::get_element( Size index) const [inline]

Returns the index -th element of the array.

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.

Parameters

index
The index of the requested element.

Returns

The requested element, or NULL if index is equal to or larger than the size of the array.

virtual base::​IInterface* mi::​IArray::get_element( Size index) [pure virtual]

Returns the index -th element of the array.

Parameters

index
The index of the requested element.

Returns

The requested element, or NULL if index is equal to or larger than the size of the array.

template< class T>

T* mi::​IArray::get_element( Size index) [inline]

Returns the index -th element of the array.

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.

Parameters

index
The index of the requested element.

Returns

The requested element, or NULL if index is equal to or larger than the size of the array.

virtual Size mi::​IArray::get_length() const [pure virtual]

Returns the size of the array. The size of an array is the number of elements in the array.

virtual Sint32 mi::​IArray::set_element( Size index, base::​IInterface* element) [pure virtual]

Sets the index -th element of the array. The object element is stored as index -th element of the array.

Parameters

index
The index where the object should be stored. The method call gets ignored if index is equal to or larger than the size of the array.
element
The object to be stored.

Returns

  • 0: Success.
  • -1: index is out of bounds.
  • -2: element is NULL or has the wrong type.