/* ----------------------------------------------------------------------- *//** * * @file HandleTraits.hpp * *//* ----------------------------------------------------------------------- */ #ifndef MADLIB_SHARED_HANDLE_TRAITS_HPP_ #define MADLIB_SHARED_HANDLE_TRAITS_HPP_ #include namespace madlib { namespace modules { /** * @brief Define mutable and immutable references * * Some modules store transition states in a composite type that they present to * the backend only as double array (for performance reasons). The elements of * the composite type "inherit" their mutability from the array. To that end, * HandleTraits takes a Handle type as template argument and correspondingly * defines mutable or immutable reference types. * * @note * HandleTraits are used for strict type safety and const-correctness. * Just using const_cast is arguably a bit shorter, but less * "correct". * * @see For an example usage, see linear.cpp. */ template struct HandleTraits; template <> struct HandleTraits > { typedef dbal::eigen_integration::ColumnVector ColumnVector; typedef dbal::eigen_integration::Matrix Matrix; typedef utils::Reference ReferenceToUInt64; typedef utils::Reference ReferenceToInt64; typedef utils::Reference ReferenceToUInt32; typedef utils::Reference ReferenceToInt32; typedef utils::Reference ReferenceToUInt16; typedef utils::Reference ReferenceToBool; typedef utils::Reference ReferenceToDouble; typedef const double* DoublePtr; typedef dbal::eigen_integration::HandleMap< const ColumnVector, TransparentHandle > ColumnVectorTransparentHandleMap; typedef dbal::eigen_integration::HandleMap > MatrixTransparentHandleMap; }; template <> struct HandleTraits > { typedef dbal::eigen_integration::ColumnVector ColumnVector; typedef dbal::eigen_integration::Matrix Matrix; typedef utils::MutableReference ReferenceToUInt64; typedef utils::MutableReference ReferenceToInt64; typedef utils::MutableReference ReferenceToUInt32; typedef utils::MutableReference ReferenceToInt32; typedef utils::MutableReference ReferenceToUInt16; typedef utils::MutableReference ReferenceToBool; typedef utils::MutableReference ReferenceToDouble; typedef double* DoublePtr; typedef dbal::eigen_integration::HandleMap > ColumnVectorTransparentHandleMap; typedef dbal::eigen_integration::HandleMap > MatrixTransparentHandleMap; }; } // namespace modules } // namespace madlib #endif