14#include <boost/mpl/and.hpp>
15#include <boost/mpl/if.hpp>
20namespace PythonInterface {
30template <
typename T>
struct is_std_vector : std::false_type {};
34template <
typename T>
struct is_std_vector<
std::vector<T>> : std::true_type {};
42template <
typename VectorType,
typename ConversionPolicy>
struct VectorRefToNumpyImpl {
43 inline PyObject *operator()(
const VectorType &cvector)
const {
47 inline PyTypeObject
const *get_pytype()
const {
return ndarrayType(); }
50template <
typename T>
struct VectorRefToNumpy_Requires_Reference_To_StdVector_Return_Type {};
65 template <
class T>
struct apply {
69 using type =
typename boost::mpl::if_c<is_std_vector<non_const_type>::value,
70 VectorRefToNumpyImpl<non_const_type, ConversionPolicy>,
71 VectorRefToNumpy_Requires_Reference_To_StdVector_Return_Type<T>>
::type;
83template <
typename VectorType>
struct VectorToNumpyImpl {
84 inline PyObject *operator()(
const VectorType &cvector)
const {
88 inline PyTypeObject
const *get_pytype()
const {
return ndarrayType(); }
91template <
typename T>
struct VectorToNumpy_Requires_StdVector_Return {};
106 using type =
typename boost::mpl::if_c<is_std_vector<non_const_type>::value,
107 VectorRefToNumpyImpl<non_const_type, Converters::Clone>,
108 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...