cisst-saw
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Public Types | Public Member Functions | List of all members
vctDynamicConstVectorRef< _elementType > Class Template Reference

Dynamic vector referencing existing memory (const) More...

#include <vctDynamicConstVectorRef.h>

Inheritance diagram for vctDynamicConstVectorRef< _elementType >:
vctDynamicConstVectorBase< vctDynamicVectorRefOwner< _elementType >, _elementType >

Public Types

typedef
vctDynamicConstVectorRef
< value_type > 
ThisType
 
typedef
vctDynamicVectorRefOwner
< value_type > 
VectorOwnerType
 
typedef
vctDynamicConstVectorBase
< vctDynamicVectorRefOwner
< value_type >, _elementType > 
BaseType
 
typedef BaseType::CopyType CopyType
 
typedef VectorOwnerType::iterator iterator
 
typedef
VectorOwnerType::const_iterator 
const_iterator
 
typedef
VectorOwnerType::reverse_iterator 
reverse_iterator
 
typedef
VectorOwnerType::const_reverse_iterator 
const_reverse_iterator
 
- Public Types inherited from vctDynamicConstVectorBase< vctDynamicVectorRefOwner< _elementType >, _elementType >
typedef
vctDynamicConstVectorBase
< vctDynamicVectorRefOwner
< _elementType >, _elementType > 
ThisType
 
typedef
vctDynamicVectorRefOwner
< _elementType > 
OwnerType
 
typedef OwnerType::iterator iterator
 
typedef OwnerType::const_iterator const_iterator
 
typedef OwnerType::reverse_iterator reverse_iterator
 
typedef
OwnerType::const_reverse_iterator 
const_reverse_iterator
 
typedef vctDynamicVector
< _elementType > 
CopyType
 
typedef vctDynamicVector
< _elementType > 
VectorValueType
 
typedef vctDynamicVector
< _elementType > 
VectorReturnType
 
typedef cmnTypeTraits< value_type > TypeTraits
 
typedef TypeTraits::BoolType BoolType
 
typedef vctReturnDynamicVector
< BoolType
BoolVectorReturnType
 

Public Member Functions

 VCT_CONTAINER_TRAITS_TYPEDEFS (_elementType)
 
 vctDynamicConstVectorRef ()
 
 vctDynamicConstVectorRef (const ThisType &other)
 
 vctDynamicConstVectorRef (size_type size, pointer data, stride_type stride=1)
 
 vctDynamicConstVectorRef (size_type size, const_pointer data, stride_type stride=1)
 
template<size_type __size, stride_type __stride, class __dataPtrType >
 vctDynamicConstVectorRef (const vctFixedSizeConstVectorBase< __size, __stride, _elementType, __dataPtrType > &otherVector)
 
template<size_type __size, stride_type __stride, class __dataPtrType >
 vctDynamicConstVectorRef (const vctFixedSizeConstVectorBase< __size, __stride, _elementType, __dataPtrType > &otherVector, size_type startPosition, size_type length)
 
template<class __vectorOwnerType >
 vctDynamicConstVectorRef (const vctDynamicConstVectorBase< __vectorOwnerType, _elementType > &otherVector)
 
template<class __vectorOwnerType >
 vctDynamicConstVectorRef (const vctDynamicConstVectorBase< __vectorOwnerType, _elementType > &otherVector, size_type startPosition, size_type length)
 
void SetRef (size_type size, const_pointer p, stride_type stride=1)
 
template<size_type __size, stride_type __stride, class __dataPtrType >
void SetRef (const vctFixedSizeConstVectorBase< __size, __stride, _elementType, __dataPtrType > &otherVector)
 
template<size_type __size, stride_type __stride, class __dataPtrType >
void SetRef (const vctFixedSizeConstVectorBase< __size, __stride, _elementType, __dataPtrType > &otherVector, size_type startPosition, size_type length) throw (std::out_of_range)
 
template<class __vectorOwnerType >
void SetRef (const vctDynamicConstVectorBase< __vectorOwnerType, _elementType > &otherVector)
 
template<class __vectorOwnerType >
void SetRef (const vctDynamicConstVectorBase< __vectorOwnerType, _elementType > &otherVector, size_type startPosition, size_type length) throw (std::out_of_range)
 
- Public Member Functions inherited from vctDynamicConstVectorBase< vctDynamicVectorRefOwner< _elementType >, _elementType >
 VCT_CONTAINER_TRAITS_TYPEDEFS (_elementType)
 
const_iterator begin (void) const
 
const_iterator end (void) const
 
const_reverse_iterator rbegin (void) const
 
const_reverse_iterator rend (void) const
 
size_type size (void) const
 
difference_type stride () const
 
bool empty () const
 
const_reference operator[] (index_type index) const
 
const_reference at (size_type index) const throw (std::out_of_range)
 
const_reference operator() (size_type index) const throw (std::out_of_range)
 
const_reference Element (size_type index) const
 
const OwnerTypeOwner (void) const
 
const_pointer Pointer (index_type index=0) const
 
bool ValidIndex (size_type index) const
 
vctDynamicConstVectorRef
< _elementType > 
Ref (const size_type size, const size_type startPosition=0) const throw (std::out_of_range)
 
value_type DotProduct (const vctDynamicConstVectorBase< __vectorOwnerType, _elementType > &otherVector) const
 
std::string ToString (void) const
 
void ToStream (std::ostream &outputStream) const
 
void ToStreamRaw (std::ostream &outputStream, const char delimiter= ' ', bool headerOnly=false, const std::string &headerPrefix="") const
 
void SerializeRaw (std::ostream &outputStream) const
 
const value_type & X (void) const
 
const value_type & Y (void) const
 
const value_type & Z (void) const
 
const value_type & W (void) const
 
vctDynamicConstVectorRef
< _elementType > 
XY (void) const
 
vctDynamicConstVectorRef
< _elementType > 
XZ (void) const
 
vctDynamicConstVectorRef
< _elementType > 
XW (void) const
 
vctDynamicConstVectorRef
< _elementType > 
YZ (void) const
 
vctDynamicConstVectorRef
< _elementType > 
YW (void) const
 
vctDynamicConstVectorRef
< _elementType > 
ZW (void) const
 
vctDynamicConstVectorRef
< _elementType > 
XYZ (void) const
 
vctDynamicConstVectorRef
< _elementType > 
YZW (void) const
 
vctDynamicConstVectorRef
< _elementType > 
XYZW (void) const
 
value_type SumOfElements (void) const
 
value_type ProductOfElements (void) const
 
value_type NormSquare (void) const
 
NormType Norm (void) const
 
bool IsNormalized (void) const
 
bool IsNormalized (_elementType tolerance) const
 
value_type L1Norm (void) const
 
value_type LinfNorm (void) const
 
value_type MaxElement (void) const
 
value_type MinElement (void) const
 
value_type MaxAbsElement (void) const
 
value_type MinAbsElement (void) const
 
void MinAndMaxElement (value_type &minElement, value_type &maxElement) const
 
bool IsPositive (void) const
 
bool IsNonNegative (void) const
 
bool IsNonPositive (void) const
 
bool IsNegative (void) const
 
bool All (void) const
 
bool Any (void) const
 
bool IsFinite (void) const
 
bool HasNaN (void) const
 
bool IsCompact (void) const
 
bool IsFortran (void) const
 
bool FastCopyCompatible (const vctDynamicConstVectorBase< __vectorOwnerType, value_type > &source) const
 
bool FastCopyCompatible (const vctFixedSizeConstVectorBase< __size, __stride, value_type, __dataPtrType > &source) const
 
bool Equal (const vctDynamicConstVectorBase< __vectorOwnerType, _elementType > &otherVector) const
 
bool operator== (const vctDynamicConstVectorBase< __vectorOwnerType, _elementType > &otherVector) const
 
bool AlmostEqual (const vctDynamicConstVectorBase< __vectorOwnerType, _elementType > &otherVector, value_type tolerance) const
 
bool AlmostEqual (const vctDynamicConstVectorBase< __vectorOwnerType, _elementType > &otherVector) const
 
bool NotEqual (const vctDynamicConstVectorBase< __vectorOwnerType, _elementType > &otherVector) const
 
bool operator!= (const vctDynamicConstVectorBase< __vectorOwnerType, _elementType > &otherVector) const
 
bool Lesser (const vctDynamicConstVectorBase< __vectorOwnerType, _elementType > &otherVector) const
 
bool LesserOrEqual (const vctDynamicConstVectorBase< __vectorOwnerType, _elementType > &otherVector) const
 
bool Greater (const vctDynamicConstVectorBase< __vectorOwnerType, _elementType > &otherVector) const
 
bool GreaterOrEqual (const vctDynamicConstVectorBase< __vectorOwnerType, _elementType > &otherVector) const
 
BoolVectorReturnType ElementwiseEqual (const vctDynamicConstVectorBase< __vectorOwnerType, _elementType > &otherVector) const
 
BoolVectorReturnType ElementwiseNotEqual (const vctDynamicConstVectorBase< __vectorOwnerType, _elementType > &otherVector) const
 
BoolVectorReturnType ElementwiseLesser (const vctDynamicConstVectorBase< __vectorOwnerType, _elementType > &otherVector) const
 
BoolVectorReturnType ElementwiseLesserOrEqual (const vctDynamicConstVectorBase< __vectorOwnerType, _elementType > &otherVector) const
 
BoolVectorReturnType ElementwiseGreater (const vctDynamicConstVectorBase< __vectorOwnerType, _elementType > &otherVector) const
 
BoolVectorReturnType ElementwiseGreaterOrEqual (const vctDynamicConstVectorBase< __vectorOwnerType, _elementType > &otherVector) const
 
bool Equal (const value_type &scalar) const
 
bool operator== (const value_type &scalar) const
 
bool NotEqual (const value_type &scalar) const
 
bool operator!= (const value_type &scalar) const
 
bool Lesser (const value_type &scalar) const
 
bool LesserOrEqual (const value_type &scalar) const
 
bool Greater (const value_type &scalar) const
 
bool GreaterOrEqual (const value_type &scalar) const
 
BoolVectorReturnType ElementwiseEqual (const value_type &scalar) const
 
BoolVectorReturnType ElementwiseNotEqual (const value_type &scalar) const
 
BoolVectorReturnType ElementwiseLesser (const value_type &scalar) const
 
BoolVectorReturnType ElementwiseLesserOrEqual (const value_type &scalar) const
 
BoolVectorReturnType ElementwiseGreater (const value_type &scalar) const
 
BoolVectorReturnType ElementwiseGreaterOrEqual (const value_type &scalar) const
 
VectorReturnType Abs (void) const
 
VectorReturnType Negation (void) const
 
VectorReturnType Floor (void) const
 
VectorReturnType Ceil (void) const
 
VectorReturnType Normalized (void) const throw (std::runtime_error)
 

Additional Inherited Members

- Protected Member Functions inherited from vctDynamicConstVectorBase< vctDynamicVectorRefOwner< _elementType >, _elementType >
void ThrowUnlessValidIndex (size_type index) const throw (std::out_of_range)
 
- Protected Attributes inherited from vctDynamicConstVectorBase< vctDynamicVectorRefOwner< _elementType >, _elementType >
OwnerType Vector
 

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);
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
_elementTypeType of elements referenced. Also defined as value_type.

Member Typedef Documentation

template<class _elementType>
typedef vctDynamicConstVectorBase<vctDynamicVectorRefOwner<value_type>, _elementType> vctDynamicConstVectorRef< _elementType >::BaseType
template<class _elementType>
typedef VectorOwnerType::const_iterator vctDynamicConstVectorRef< _elementType >::const_iterator
template<class _elementType>
typedef VectorOwnerType::const_reverse_iterator vctDynamicConstVectorRef< _elementType >::const_reverse_iterator
template<class _elementType>
typedef BaseType::CopyType vctDynamicConstVectorRef< _elementType >::CopyType
template<class _elementType>
typedef VectorOwnerType::iterator vctDynamicConstVectorRef< _elementType >::iterator
template<class _elementType>
typedef VectorOwnerType::reverse_iterator vctDynamicConstVectorRef< _elementType >::reverse_iterator
template<class _elementType>
typedef vctDynamicConstVectorRef<value_type> vctDynamicConstVectorRef< _elementType >::ThisType
template<class _elementType>
typedef vctDynamicVectorRefOwner<value_type> vctDynamicConstVectorRef< _elementType >::VectorOwnerType

Constructor & Destructor Documentation

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

Default constructor initializes the vector reference to NULL

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

Copy constructor

template<class _elementType>
vctDynamicConstVectorRef< _elementType >::vctDynamicConstVectorRef ( size_type  size,
pointer  data,
stride_type  stride = 1 
)
inline
template<class _elementType>
vctDynamicConstVectorRef< _elementType >::vctDynamicConstVectorRef ( size_type  size,
const_pointer  data,
stride_type  stride = 1 
)
inline
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.
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.
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.
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.

Member Function Documentation

template<class _elementType>
void vctDynamicConstVectorRef< _elementType >::SetRef ( size_type  size,
const_pointer  p,
stride_type  stride = 1 
)
inline
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.
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).
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.
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).
template<class _elementType>
vctDynamicConstVectorRef< _elementType >::VCT_CONTAINER_TRAITS_TYPEDEFS ( _elementType  )

The documentation for this class was generated from the following file: