ERC CISST - cisst software

vctDynamicConstVectorRef< _elementType > Class Template Reference
[Vectors]

#include <vctDynamicConstVectorRef.h>

Inheritance diagram for vctDynamicConstVectorRef< _elementType >:

Inheritance graph
[legend]
Collaboration diagram for vctDynamicConstVectorRef< _elementType >:

Collaboration graph
[legend]
List of all members.

Detailed Description

template<class _elementType>
class vctDynamicConstVectorRef< _elementType >

Dynamic vector referencing existing memory (const).

The class vctDynamicConstVectorRef allows to create a vector 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, size, stride). 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 vector, one can do:

  vctDynamicVector<double> wholeVector(10);
  vctRandom(wholeVector, -10.0, 10.0);
  vctDynamicConstVectorRef<double> first5;
  first5.SetRef(wholeVector, 0, 5);
  std::cout << first5 << " " << first5.SumOfElements() << std::endl;

Note:
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.

vctDynamicConstVectorRef 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 vctDynamicVectorRef.

See also:
vctDynamicVector, vctDynamicVectorRef
Parameters:
_elementType Type of elements referenced. Also defined as value_type.

Definition at line 80 of file vctDynamicConstVectorRef.h.

Public Types

Public Member Functions

Public Attributes


Member Typedef Documentation

template<class _elementType>
typedef vctDynamicConstVectorRef<value_type> vctDynamicConstVectorRef< _elementType >::ThisType

Type of the vector itself.

Reimplemented from vctDynamicConstVectorBase< vctDynamicVectorRefOwner< _elementType >, _elementType >.

Definition at line 85 of file vctDynamicConstVectorRef.h.

template<class _elementType>
typedef BaseType::CopyType vctDynamicConstVectorRef< _elementType >::CopyType

The type used to create a copy.

Reimplemented from vctDynamicConstVectorBase< vctDynamicVectorRefOwner< _elementType >, _elementType >.

Definition at line 88 of file vctDynamicConstVectorRef.h.

template<class _elementType>
typedef VectorOwnerType::iterator vctDynamicConstVectorRef< _elementType >::iterator

Iterator on the elements of the vector.

Reimplemented from vctDynamicConstVectorBase< vctDynamicVectorRefOwner< _elementType >, _elementType >.

Definition at line 89 of file vctDynamicConstVectorRef.h.

template<class _elementType>
typedef VectorOwnerType::const_iterator vctDynamicConstVectorRef< _elementType >::const_iterator

Const iterator on the elements of the vector.

Reimplemented from vctDynamicConstVectorBase< vctDynamicVectorRefOwner< _elementType >, _elementType >.

Definition at line 90 of file vctDynamicConstVectorRef.h.

template<class _elementType>
typedef VectorOwnerType::reverse_iterator vctDynamicConstVectorRef< _elementType >::reverse_iterator

Reverse iterator on the elements of the vector.

Reimplemented from vctDynamicConstVectorBase< vctDynamicVectorRefOwner< _elementType >, _elementType >.

Definition at line 91 of file vctDynamicConstVectorRef.h.

template<class _elementType>
typedef VectorOwnerType::const_reverse_iterator vctDynamicConstVectorRef< _elementType >::const_reverse_iterator

Const reverse iterator on the elements of the vector.

Reimplemented from vctDynamicConstVectorBase< vctDynamicVectorRefOwner< _elementType >, _elementType >.

Definition at line 92 of file vctDynamicConstVectorRef.h.


Constructor & Destructor Documentation

template<class _elementType>
vctDynamicConstVectorRef< _elementType >::vctDynamicConstVectorRef (  )  [inline]

Default constructor initializes the vector reference to NULL

Definition at line 95 of file vctDynamicConstVectorRef.h.

template<class _elementType>
vctDynamicConstVectorRef< _elementType >::vctDynamicConstVectorRef ( const ThisType other  )  [inline]

Copy constructor

Definition at line 99 of file vctDynamicConstVectorRef.h.

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

template<class _elementType>
template<size_type __size, stride_type __stride, class __dataPtrType>
vctDynamicConstVectorRef< _elementType >::vctDynamicConstVectorRef ( const vctFixedSizeConstVectorBase< __size, __stride, _elementType, __dataPtrType > &  otherVector  )  [inline]

Initialize a dynamic reference to a fixed-size vector.

Note:
This constructor is non-explicit, and allows automatic conversion from a fixed-size vector to a dynamic vector representation.

The size and stride values are taken from the fixed size vector.

Definition at line 119 of file vctDynamicConstVectorRef.h.

References vctDynamicConstVectorRef< _elementType >::SetRef().

template<class _elementType>
template<size_type __size, stride_type __stride, class __dataPtrType>
vctDynamicConstVectorRef< _elementType >::vctDynamicConstVectorRef ( const vctFixedSizeConstVectorBase< __size, __stride, _elementType, __dataPtrType > &  otherVector,
size_type  startPosition,
size_type  length 
) [inline]

Initialize a dynamic reference to specified subvector of a fixed-size vector.

Note:
This constructor allows automatic conversion from a fixed-size vector to a dynamic vector representation.

The stride values are taken from the fixed size vector, but the starting point and length must be specified.

Definition at line 131 of file vctDynamicConstVectorRef.h.

References vctDynamicConstVectorRef< _elementType >::SetRef().

template<class _elementType>
template<class __vectorOwnerType>
vctDynamicConstVectorRef< _elementType >::vctDynamicConstVectorRef ( const vctDynamicConstVectorBase< __vectorOwnerType, _elementType > &  otherVector  )  [inline]

Initialize a dynamic reference to a dynamic vector.

Note:
the starting point, size, and stride, are taken from the other vector.

Definition at line 141 of file vctDynamicConstVectorRef.h.

References vctDynamicConstVectorRef< _elementType >::SetRef().

template<class _elementType>
template<class __vectorOwnerType>
vctDynamicConstVectorRef< _elementType >::vctDynamicConstVectorRef ( const vctDynamicConstVectorBase< __vectorOwnerType, _elementType > &  otherVector,
size_type  startPosition,
size_type  length 
) [inline]

Initialize a dynamic reference to a specified subvector of a dynamic vector.

Note:
the stride is taken from the other vector, but the starting point and the length must be specified.

Definition at line 151 of file vctDynamicConstVectorRef.h.

References vctDynamicConstVectorRef< _elementType >::SetRef().


Member Function Documentation

template<class _elementType>
template<size_type __size, stride_type __stride, class __dataPtrType>
void vctDynamicConstVectorRef< _elementType >::SetRef ( const vctFixedSizeConstVectorBase< __size, __stride, _elementType, __dataPtrType > &  otherVector  )  [inline]

Set a dynamic reference to a fixed-size vector

Note:
the size and memory stride of this reference will be equal to the size and memory stride of the input vector.

Definition at line 166 of file vctDynamicConstVectorRef.h.

References vctFixedSizeConstVectorBase< _size, _stride, _elementType, _dataPtrType >::Pointer(), vctDynamicConstVectorRef< _elementType >::SetRef(), vctFixedSizeConstVectorBase< _size, _stride, _elementType, _dataPtrType >::size(), and vctFixedSizeConstVectorBase< _size, _stride, _elementType, _dataPtrType >::stride().

template<class _elementType>
template<size_type __size, stride_type __stride, class __dataPtrType>
void vctDynamicConstVectorRef< _elementType >::SetRef ( const vctFixedSizeConstVectorBase< __size, __stride, _elementType, __dataPtrType > &  otherVector,
size_type  startPosition,
size_type  length 
) throw (std::out_of_range) [inline]

Set a dynamic reference to a specified subvector of a fixed-size vector

Note:
the memory stride of this reference will be equal to the memory stride of the input vector.

This method verifies that the size of this vector does not exceed the size of the input vector (otherwise cmnThrow is used to throw std::out_of_range).

Definition at line 178 of file vctDynamicConstVectorRef.h.

References cmnThrow(), and vctDynamicConstVectorRef< _elementType >::SetRef().

template<class _elementType>
template<class __vectorOwnerType>
void vctDynamicConstVectorRef< _elementType >::SetRef ( const vctDynamicConstVectorBase< __vectorOwnerType, _elementType > &  otherVector  )  [inline]

Set a dynamic reference to a dynamic vector

Note:
the size and memory stride of this reference will be equal to the size memory stride of the input vector.

Definition at line 192 of file vctDynamicConstVectorRef.h.

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

template<class _elementType>
template<class __vectorOwnerType>
void vctDynamicConstVectorRef< _elementType >::SetRef ( const vctDynamicConstVectorBase< __vectorOwnerType, _elementType > &  otherVector,
size_type  startPosition,
size_type  length 
) throw (std::out_of_range) [inline]

Set a dynamic reference to a specified subvector of dynamic vector

Note:
the memory stride of this reference will be equal to the memory stride of the input vector.

This method verifies that the size of this vector does not exceed the size of the input vector (otherwise cmnThrow is used to throw std::out_of_range).

Definition at line 204 of file vctDynamicConstVectorRef.h.

References cmnThrow(), and vctDynamicConstVectorRef< _elementType >::SetRef().


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