ERC CISST - cisst software

vctDynamicConstNArrayRef< _elementType, _dimension > Class Template Reference
[Vectors]

#include <vctDynamicConstNArrayRef.h>

Inheritance diagram for vctDynamicConstNArrayRef< _elementType, _dimension >:

Inheritance graph
[legend]
Collaboration diagram for vctDynamicConstNArrayRef< _elementType, _dimension >:

Collaboration graph
[legend]
List of all members.

Detailed Description

template<class _elementType, vct::size_type _dimension>
class vctDynamicConstNArrayRef< _elementType, _dimension >

Dynamic nArray referencing existing memory (const).

The class vctDynamicConstNArrayRef allows to create a nArray overlaying an existing block of memory. It can be used to manipulate a container created by another toolkit (i.e. OpenGL, vtk, ...) or a cisstVector container using different parameters (different size, storage order or stride).

To setup the overlay, one can use either the constructors or the SetRef methods. When used with a cisst container, the SetRef methods can infer some of the memory layout information (pointer on first element, sizes, strides). When used to overlay existing memory referenced by a pointer, the user has to provide all the required information. In any case, the Ref object doesn't allocate nor free memory.

Finally, as this overlay is const, it can be used to make sure the referenced content is not modified.

For example to manipulate the first five elements of a nArray, one can do:

  vctDynamicNArray<double, 2> wholeNArray(size_type(10, 10));
  vctRandom(wholeNArray, -10.0, 10.0);
  vctDynamicNArrayRef<double, 2> first5x5;
  first5x5.SetRef(wholeNArray, size_type(0, 0), size_type(5, 5));
  std::cout << first5x5 << " " << first5x5.SumOfElements() << std::endl;

Note:
On top of the SetRef methods provided for the cisst vectors and matrices (see vctDynamicVectorRef and vctDynamicMatrixRef), the ref classes for nArrays provides the methods SubarrayOf (re-size, same dimension), PermutationOf (same dimension, same sizes but different ordering of dimensions), SliceOf (reduce dimension by 1). By combining different Refs created using a mix of these methods, one can create any desired overlay.

Make sure the underlying memory is not freed after the Ref object is created and before it is used. This would lead to faulty memory access and potential bugs.

vctDynamicConstNArrayRef only performs const operations even if it stores a non-const value_type *. It can be initialized with either value_type * or const value_type *. For a non-const Ref, see vctDynamicNArrayRef.

See also:
vctDynamicNArray, vctDynamicNArrayRef
Parameters:
_elementType Type of elements referenced. Also defined as value_type.
_dimension Dimension of the const nArray ref.

Definition at line 90 of file vctDynamicConstNArrayRef.h.

Public Types

Public Member Functions

Public Attributes


Member Typedef Documentation

template<class _elementType, vct::size_type _dimension>
typedef vctDynamicConstNArrayRef<_elementType, DIMENSION> vctDynamicConstNArrayRef< _elementType, _dimension >::ThisType

Type of the nArray itself.

Reimplemented from vctDynamicConstNArrayBase< vctDynamicNArrayRefOwner< _elementType, _dimension >, _elementType, _dimension >.

Definition at line 100 of file vctDynamicConstNArrayRef.h.


Constructor & Destructor Documentation

template<class _elementType, vct::size_type _dimension>
vctDynamicConstNArrayRef< _elementType, _dimension >::vctDynamicConstNArrayRef ( const ThisType other  )  [inline]

Copy constructor

Definition at line 115 of file vctDynamicConstNArrayRef.h.

References vctDynamicConstNArrayBase< _nArrayOwnerType, _elementType, _dimension >::Pointer(), vctDynamicConstNArrayRef< _elementType, _dimension >::SetRef(), vctDynamicConstNArrayBase< _nArrayOwnerType, _elementType, _dimension >::sizes(), and vctDynamicConstNArrayBase< _nArrayOwnerType, _elementType, _dimension >::strides().

template<class _elementType, vct::size_type _dimension>
vctDynamicConstNArrayRef< _elementType, _dimension >::vctDynamicConstNArrayRef ( const_pointer  dataPointer,
const nsize_type &  sizes,
const nstride_type &  strides 
) [inline]

Create a reference to a memory location.

Note:
see corresponding SetRef method below

Definition at line 124 of file vctDynamicConstNArrayRef.h.

References vctDynamicConstNArrayRef< _elementType, _dimension >::SetRef().

template<class _elementType, vct::size_type _dimension>
vctDynamicConstNArrayRef< _elementType, _dimension >::vctDynamicConstNArrayRef ( pointer  dataPointer,
const nsize_type &  sizes,
const nstride_type &  strides 
) [inline]

Create a reference to a memory location.

Note:
see corresponding SetRef method below

Definition at line 132 of file vctDynamicConstNArrayRef.h.

References vctDynamicConstNArrayRef< _elementType, _dimension >::SetRef().

template<class _elementType, vct::size_type _dimension>
template<class __ownerType>
vctDynamicConstNArrayRef< _elementType, _dimension >::vctDynamicConstNArrayRef ( const vctDynamicConstNArrayBase< __ownerType, value_type, DIMENSION > &  otherNArray  )  [inline]

Create a reference to an nArray.

Note:
see corresponding SetRef method below

Definition at line 141 of file vctDynamicConstNArrayRef.h.

References vctDynamicConstNArrayRef< _elementType, _dimension >::SetRef().

template<class _elementType, vct::size_type _dimension>
template<class __ownerType>
vctDynamicConstNArrayRef< _elementType, _dimension >::vctDynamicConstNArrayRef ( const vctDynamicConstVectorBase< __ownerType, value_type > &  vector  )  [inline]

Create a reference to a dynamic vector.

Note:
see corresponding SetRef method below

Definition at line 150 of file vctDynamicConstNArrayRef.h.

References vctDynamicConstNArrayRef< _elementType, _dimension >::SetRef().

template<class _elementType, vct::size_type _dimension>
template<size_type __size, stride_type __stride, typename __dataPtrType>
vctDynamicConstNArrayRef< _elementType, _dimension >::vctDynamicConstNArrayRef ( const vctFixedSizeConstVectorBase< __size, __stride, value_type, __dataPtrType > &  vector  )  [inline]

Create a reference to a fixed-size vector.

Note:
see corresponding SetRef method below

Definition at line 159 of file vctDynamicConstNArrayRef.h.

References vctDynamicConstNArrayRef< _elementType, _dimension >::SetRef().

template<class _elementType, vct::size_type _dimension>
template<class __ownerType>
vctDynamicConstNArrayRef< _elementType, _dimension >::vctDynamicConstNArrayRef ( const vctDynamicConstMatrixBase< __ownerType, value_type > &  matrix  )  [inline]

Create a reference to a dynamic matrix.

Note:
see corresponding SetRef method below

Definition at line 168 of file vctDynamicConstNArrayRef.h.

References vctDynamicConstNArrayRef< _elementType, _dimension >::SetRef().

template<class _elementType, vct::size_type _dimension>
template<size_type __rows, size_type __cols, stride_type __rowStride, stride_type __colStride, typename __dataPtrType>
vctDynamicConstNArrayRef< _elementType, _dimension >::vctDynamicConstNArrayRef ( const vctFixedSizeConstMatrixBase< __rows, __cols, __rowStride, __colStride, value_type, __dataPtrType > &  matrix  )  [inline]

Create a reference to a fixed-size matrix.

Note:
see corresponding SetRef method below

Definition at line 177 of file vctDynamicConstNArrayRef.h.

References vctDynamicConstNArrayRef< _elementType, _dimension >::SetRef().


Member Function Documentation

template<class _elementType, vct::size_type _dimension>
void vctDynamicConstNArrayRef< _elementType, _dimension >::SetRef ( const_pointer  dataPointer,
const nsize_type &  sizes,
const nstride_type &  strides 
) [inline]

Set a reference to a memory location. The user should specify all the parameters of the referenced memory, including a start memory address.

Definition at line 189 of file vctDynamicConstNArrayRef.h.

References vctDynamicConstNArrayBase< vctDynamicNArrayRefOwner< _elementType, _dimension >, _elementType, _dimension >::NArray, and vctDynamicNArrayRefOwner< _elementType, _dimension >::SetRef().

Referenced by vctDynamicConstNArrayRef< _elementType, _dimension >::PermutationOf(), vctDynamicConstNArrayRef< _elementType, _dimension >::SetRef(), vctDynamicConstNArrayRef< _elementType, _dimension >::SliceOf(), vctDynamicConstNArrayRef< _elementType, _dimension >::SubarrayOf(), and vctDynamicConstNArrayRef< _elementType, _dimension >::vctDynamicConstNArrayRef().

template<class _elementType, vct::size_type _dimension>
template<class __ownerType>
void vctDynamicConstNArrayRef< _elementType, _dimension >::SetRef ( const vctDynamicConstNArrayBase< __ownerType, value_type, DIMENSION > &  otherNArray  )  [inline]

Set a reference to an nArray. The reference will have identical dimensions, sizes and strides as the input nArray.

Definition at line 198 of file vctDynamicConstNArrayRef.h.

References vctDynamicConstNArrayBase< _nArrayOwnerType, _elementType, _dimension >::Pointer(), vctDynamicConstNArrayRef< _elementType, _dimension >::SetRef(), vctDynamicConstNArrayBase< _nArrayOwnerType, _elementType, _dimension >::sizes(), and vctDynamicConstNArrayBase< _nArrayOwnerType, _elementType, _dimension >::strides().

template<class _elementType, vct::size_type _dimension>
template<class __ownerType>
void vctDynamicConstNArrayRef< _elementType, _dimension >::SubarrayOf ( const vctDynamicConstNArrayBase< __ownerType, value_type, DIMENSION > &  otherNArray,
const nsize_type &  startPosition,
const nsize_type &  lengths 
) [inline]

Set a reference to a subarray of an nArray.

Parameters:
otherNArray the nArray over which to set this reference
startPosition vector of indices of the element position where the reference will start
lengths the number of elements to reference in each dimension
Note:
Preserves the number of dimensions.

Definition at line 211 of file vctDynamicConstNArrayRef.h.

References CMN_ASSERT, vctDynamicConstNArrayBase< vctDynamicNArrayRefOwner< _elementType, _dimension >, _elementType, _dimension >::LesserOrEqual(), vctDynamicConstNArrayBase< _nArrayOwnerType, _elementType, _dimension >::Pointer(), vctDynamicConstNArrayRef< _elementType, _dimension >::SetRef(), vctDynamicConstNArrayBase< _nArrayOwnerType, _elementType, _dimension >::sizes(), and vctDynamicConstNArrayBase< _nArrayOwnerType, _elementType, _dimension >::strides().

Referenced by vctDynamicConstNArrayBase< vctDynamicNArrayRefOwner< _elementType, _dimension >, _elementType, _dimension >::Subarray().

template<class _elementType, vct::size_type _dimension>
template<class __ownerType>
void vctDynamicConstNArrayRef< _elementType, _dimension >::PermutationOf ( const vctDynamicConstNArrayBase< __ownerType, value_type, DIMENSION > &  otherNArray,
const ndimension_type &  dimensions 
) [inline]

Set a reference to an nArray with a permutation of its strides.

Parameters:
otherNArray the nArray over which to set this reference
dimensions a sequence of dimension numbers representing the permuted order of strides
Note:
Preserves the number of dimensions.

Definition at line 227 of file vctDynamicConstNArrayRef.h.

References vctDynamicConstNArrayBase< _nArrayOwnerType, _elementType, _dimension >::Pointer(), vctDynamicConstNArrayRef< _elementType, _dimension >::SetRef(), vctDynamicConstNArrayBase< _nArrayOwnerType, _elementType, _dimension >::size(), vctDynamicConstNArrayBase< vctDynamicNArrayRefOwner< _elementType, _dimension >, _elementType, _dimension >::sizes(), vctDynamicConstNArrayBase< _nArrayOwnerType, _elementType, _dimension >::stride(), and vctDynamicConstNArrayBase< vctDynamicNArrayRefOwner< _elementType, _dimension >, _elementType, _dimension >::strides().

Referenced by vctDynamicConstNArrayBase< vctDynamicNArrayRefOwner< _elementType, _dimension >, _elementType, _dimension >::Permutation().

template<class _elementType, vct::size_type _dimension>
template<class __ownerType>
void vctDynamicConstNArrayRef< _elementType, _dimension >::SliceOf ( const vctDynamicConstNArrayBase< __ownerType, value_type, DIMENSION+1 > &  otherNArray,
dimension_type  dimension,
size_type  index 
) [inline]

Set a reference to an (n-1)-dimension slice of an n-dimension nArray.

Parameters:
otherNArray the nArray over which to set this reference
dimension the dimension number of the direction by which to reduce
slice the index number in the dimension specified by which to set the reference
Note:
The number of dimensions is reduced by one.

Definition at line 257 of file vctDynamicConstNArrayRef.h.

References vctDynamicConstNArrayBase< _nArrayOwnerType, _elementType, _dimension >::Pointer(), vctDynamicConstNArrayRef< _elementType, _dimension >::SetRef(), vctDynamicConstNArrayBase< _nArrayOwnerType, _elementType, _dimension >::sizes(), vctDynamicConstNArrayBase< vctDynamicNArrayRefOwner< _elementType, _dimension >, _elementType, _dimension >::sizes(), vctDynamicConstNArrayBase< vctDynamicNArrayRefOwner< _elementType, _dimension >, _elementType, _dimension >::strides(), and vctDynamicConstNArrayBase< _nArrayOwnerType, _elementType, _dimension >::strides().

template<class _elementType, vct::size_type _dimension>
template<class __ownerType>
void vctDynamicConstNArrayRef< _elementType, _dimension >::SetRef ( const vctDynamicConstVectorBase< __ownerType, value_type > &  vector  )  [inline]

Set a reference to a dynamic vector. The reference will have identical size and stride as the input vector.

Definition at line 314 of file vctDynamicConstNArrayRef.h.

References vctDynamicConstVectorBase< _vectorOwnerType, _elementType >::Pointer(), vctDynamicConstNArrayRef< _elementType, _dimension >::SetRef(), vctDynamicConstVectorBase< _vectorOwnerType, _elementType >::size(), and vctDynamicConstVectorBase< _vectorOwnerType, _elementType >::stride().

template<class _elementType, vct::size_type _dimension>
template<size_type __size, stride_type __stride, typename __dataPtrType>
void vctDynamicConstNArrayRef< _elementType, _dimension >::SetRef ( const vctFixedSizeConstVectorBase< __size, __stride, value_type, __dataPtrType > &  vector  )  [inline]

Set a reference to a fixed-size vector. The reference will have identical size and stride as the input vector.

Definition at line 323 of file vctDynamicConstNArrayRef.h.

References vctFixedSizeConstVectorBase< _size, _stride, _elementType, _dataPtrType >::Pointer(), and vctDynamicConstNArrayRef< _elementType, _dimension >::SetRef().

template<class _elementType, vct::size_type _dimension>
template<class __ownerType>
void vctDynamicConstNArrayRef< _elementType, _dimension >::SetRef ( const vctDynamicConstMatrixBase< __ownerType, value_type > &  matrix  )  [inline]

Set a reference to a dynamic matrix. The reference will have identical sizes and strides as the input matrix.

Definition at line 332 of file vctDynamicConstNArrayRef.h.

References vctDynamicConstMatrixBase< _matrixOwnerType, _elementType >::col_stride(), vctDynamicConstMatrixBase< _matrixOwnerType, _elementType >::cols(), vctDynamicConstMatrixBase< _matrixOwnerType, _elementType >::Pointer(), vctDynamicConstMatrixBase< _matrixOwnerType, _elementType >::row_stride(), vctDynamicConstMatrixBase< _matrixOwnerType, _elementType >::rows(), and vctDynamicConstNArrayRef< _elementType, _dimension >::SetRef().

template<class _elementType, vct::size_type _dimension>
template<size_type __rows, size_type __cols, stride_type __rowStride, stride_type __colStride, typename __dataPtrType>
void vctDynamicConstNArrayRef< _elementType, _dimension >::SetRef ( const vctFixedSizeConstMatrixBase< __rows, __cols, __rowStride, __colStride, value_type, __dataPtrType > &  matrix  )  [inline]

Set a reference to a fixed-size matrix. The reference will have identical sizes and strides as the input matrix.

Definition at line 343 of file vctDynamicConstNArrayRef.h.

References vctDynamicConstNArrayRef< _elementType, _dimension >::SetRef().


The documentation for this class was generated from the following file:
erc-cisst-devel<at>lists.johnshopkins.edu