13#include <boost/mpl/and.hpp>
14#include <boost/mpl/if.hpp>
19namespace PythonInterface {
29template <
typename T>
struct is_std_vector : std::false_type {};
33template <
typename T>
struct is_std_vector<
std::vector<T>> : std::true_type {};
41template <
typename VectorType,
typename ConversionPolicy>
struct VectorRefToNumpyImpl {
42 inline PyObject *operator()(
const VectorType &cvector)
const {
46 inline PyTypeObject
const *get_pytype()
const {
return ndarrayType(); }
49template <
typename T>
struct VectorRefToNumpy_Requires_Reference_To_StdVector_Return_Type {};
64 template <
class T>
struct apply {
68 using type =
typename boost::mpl::if_c<is_std_vector<non_const_type>::value,
69 VectorRefToNumpyImpl<non_const_type, ConversionPolicy>,
70 VectorRefToNumpy_Requires_Reference_To_StdVector_Return_Type<T>>
::type;
82template <
typename VectorType>
struct VectorToNumpyImpl {
83 inline PyObject *operator()(
const VectorType &cvector)
const {
87 inline PyTypeObject
const *get_pytype()
const {
return ndarrayType(); }
90template <
typename T>
struct VectorToNumpy_Requires_StdVector_Return {};
105 using type =
typename boost::mpl::if_c<is_std_vector<non_const_type>::value,
106 VectorRefToNumpyImpl<non_const_type, Converters::Clone>,
107 VectorToNumpy_Requires_StdVector_Return<T>>
::type;
MANTID_PYTHONINTERFACE_CORE_DLL PyTypeObject * ndarrayType()
Return the type object for a numpy.NDArray.
Helper class which provides the Collimation Length for SANS instruments.
Converter that takes a std::vector and converts it into a flat numpy array.
typename std::remove_const< typename std::remove_reference< T >::type >::type non_const_type
typename boost::mpl::if_c< is_std_vector< non_const_type >::value, VectorRefToNumpyImpl< non_const_type, ConversionPolicy >, VectorRefToNumpy_Requires_Reference_To_StdVector_Return_Type< T > >::type type
Implements a return value policy that returns a numpy array from a rerence to a std::vector.
typename boost::mpl::if_c< is_std_vector< non_const_type >::value, VectorRefToNumpyImpl< non_const_type, Converters::Clone >, VectorToNumpy_Requires_StdVector_Return< T > >::type type
typename std::remove_const< typename std::remove_reference< T >::type >::type non_const_type
Implements a return value policy that returns a numpy array from a function returning a std::vector b...