cisst-saw
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Static Public Member Functions | List of all members
vctFastCopy Class Reference

Container class for fast copy related methods. More...

#include <vctFastCopy.h>

Static Public Member Functions

template<class _destinationVectorType , class _sourceVectorType >
static bool VectorCopy (_destinationVectorType &destination, const _sourceVectorType &source, bool performSafetyChecks)
 
template<class _destinationMatrixType , class _sourceMatrixType >
static bool MatrixCopy (_destinationMatrixType &destination, const _sourceMatrixType &source, bool performSafetyChecks)
 
template<class _destinationNArrayType , class _sourceNArrayType >
static bool NArrayCopy (_destinationNArrayType &destination, const _sourceNArrayType &source, bool performSafetyChecks)
 
template<class _vector1Type , class _vector2Type >
static bool VectorCopyCompatible (const _vector1Type &vector1, const _vector2Type &vector2)
 
template<class _matrix1Type , class _matrix2Type >
static bool MatrixCopyCompatible (const _matrix1Type &matrix1, const _matrix2Type &matrix2)
 
template<class _nArray1Type , class _nArray2Type >
static bool NArrayCopyCompatible (const _nArray1Type &nArray1, const _nArray2Type &nArray2)
 

Static Public Attributes

static const bool SkipChecks = false
 
static const bool PerformChecks = true
 

Static Protected Member Functions

template<class _vector1Type , class _vector2Type >
static bool VectorSizeCompatible (const _vector1Type &vector1, const _vector2Type &vector2)
 
template<class _container1Type , class _container2Type >
static bool ContainerSizesCompatible (const _container1Type &container1, const _container2Type &container2)
 
template<class _vector1Type , class _vector2Type >
static bool VectorStrideCompatible (const _vector1Type &vector1, const _vector2Type &vector2)
 
template<class _matrix1Type , class _matrix2Type >
static bool MatrixStridesCompatible (const _matrix1Type &matrix1, const _matrix2Type &matrix2)
 
template<class _nArray1Type , class _nArray2Type >
static bool NArrayStridesCompatible (const _nArray1Type &nArray1, const _nArray2Type &nArray2)
 
template<class _vector1Type , class _vector2Type >
static void ThrowUnlessValidVectorSizes (const _vector1Type &vector1, const _vector2Type &vector2) throw (std::runtime_error)
 
template<class _container1Type , class _container2Type >
static void ThrowUnlessValidContainerSizes (const _container1Type &container1, const _container2Type &container2) throw (std::runtime_error)
 

Detailed Description

Container class for fast copy related methods.

The static methods in this class should not be used directly. These are helper methods used by the containers methods. To perform a FastCopy (aka memcpy), always use the methods FastCopyOf and FastCopyCompatible defined for vctFixedSizeVector, vctFixedSizeMatrix, vctDynamicVector, vctDynamicMatrix and vctDynamicNArray.

Member Function Documentation

template<class _container1Type , class _container2Type >
static bool vctFastCopy::ContainerSizesCompatible ( const _container1Type &  container1,
const _container2Type &  container2 
)
inlinestaticprotected
template<class _destinationMatrixType , class _sourceMatrixType >
static bool vctFastCopy::MatrixCopy ( _destinationMatrixType &  destination,
const _sourceMatrixType &  source,
bool  performSafetyChecks 
)
inlinestatic

Function to use memcpy whenever possible. This is not really and engine since it has no loop nor plugable operation, but it performs a similar size check as other engines. This method will attempt to copy either the whole matrix using a single memcpy or one memcpy for each row or column whenever possible.

First the method performs a serie of checks to make sure both matrices are compatible. If the sizes are incorrect, the method will throw an exception as do all cisstVector engines. If the strides are not compatible for a memcpy, the method return false. The safety checks can be skipped by turning the second parameter (performSafetyChecks) to false.

Then the method will test if both matrices are compact to figure out if a single memcpy is possible. Otherwise, the methods will compare the strides, assuming that either both row or column strides are equal to one.

Note
If the safety checks are turned off, the caller must make sure that for both matrices have the same sizes and satisfy either: -1- both compact, -2- both have column strides equal to one OR -3- both have row strides equal to one. If these conditions are not satified, a memcpy might be performed on unallocated memory.
template<class _matrix1Type , class _matrix2Type >
static bool vctFastCopy::MatrixCopyCompatible ( const _matrix1Type &  matrix1,
const _matrix2Type &  matrix2 
)
inlinestatic
template<class _matrix1Type , class _matrix2Type >
static bool vctFastCopy::MatrixStridesCompatible ( const _matrix1Type &  matrix1,
const _matrix2Type &  matrix2 
)
inlinestaticprotected
template<class _destinationNArrayType , class _sourceNArrayType >
static bool vctFastCopy::NArrayCopy ( _destinationNArrayType &  destination,
const _sourceNArrayType &  source,
bool  performSafetyChecks 
)
inlinestatic

Function to use memcpy whenever possible. This is not really and engine since it has no loop nor plugable operation, but it performs a similar size check as other engines. This method will attempt to copy either the whole nArray using a single memcpy.

template<class _nArray1Type , class _nArray2Type >
static bool vctFastCopy::NArrayCopyCompatible ( const _nArray1Type &  nArray1,
const _nArray2Type &  nArray2 
)
inlinestatic
template<class _nArray1Type , class _nArray2Type >
static bool vctFastCopy::NArrayStridesCompatible ( const _nArray1Type &  nArray1,
const _nArray2Type &  nArray2 
)
inlinestaticprotected
template<class _container1Type , class _container2Type >
static void vctFastCopy::ThrowUnlessValidContainerSizes ( const _container1Type &  container1,
const _container2Type &  container2 
)
throw (std::runtime_error
)
inlinestaticprotected
template<class _vector1Type , class _vector2Type >
static void vctFastCopy::ThrowUnlessValidVectorSizes ( const _vector1Type &  vector1,
const _vector2Type &  vector2 
)
throw (std::runtime_error
)
inlinestaticprotected

Helper function to throw an exception whenever sizes mismatch. This enforces that a standard message is sent.

template<class _destinationVectorType , class _sourceVectorType >
static bool vctFastCopy::VectorCopy ( _destinationVectorType &  destination,
const _sourceVectorType &  source,
bool  performSafetyChecks 
)
inlinestatic

Function to use memcpy whenever possible. This is not really and engine since it has no loop nor plugable operation, but it performs a similar size check as other engines.

template<class _vector1Type , class _vector2Type >
static bool vctFastCopy::VectorCopyCompatible ( const _vector1Type &  vector1,
const _vector2Type &  vector2 
)
inlinestatic

Helper functions to test if a fast copy is possible.

template<class _vector1Type , class _vector2Type >
static bool vctFastCopy::VectorSizeCompatible ( const _vector1Type &  vector1,
const _vector2Type &  vector2 
)
inlinestaticprotected

Helper functions to test if sizes or strides are compatible.

template<class _vector1Type , class _vector2Type >
static bool vctFastCopy::VectorStrideCompatible ( const _vector1Type &  vector1,
const _vector2Type &  vector2 
)
inlinestaticprotected

Member Data Documentation

const bool vctFastCopy::PerformChecks = true
static
const bool vctFastCopy::SkipChecks = false
static

Flags used to skip or perform safety checks in FastCopy.


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