5#include <boost/python.hpp>
6#include <boost/python/class.hpp>
7#include <boost/python/return_value_policy.hpp>
9#include <fmt/ostream.h>
14namespace bp = boost::python;
21template <
typename MatrixType,
typename Class>
struct eigen_member {
23 typedef Eigen::Ref<const MatrixType> ConstMatRef;
25 eigen_member(MatrixType Class::*which)
28 Eigen::Ref<MatrixType> operator()(Class &c)
const {
return c.*m_which; }
30 void operator()(Class &c,
31 typename bp::detail::value_arg<ConstMatRef>::type d)
const {
36 MatrixType Class::*m_which;
45template <
class C,
class MatrixType>
47 typedef Eigen::Ref<MatrixType> RefType;
48 return bp::make_function(
49 internal::eigen_member<MatrixType, C>(v),
50 bp::return_value_policy<bp::return_by_value,
51 bp::with_custodian_and_ward_postcall<0UL, 1UL>>(),
52 boost::mpl::vector2<RefType, C &>());
55template <
class C,
class MatrixType,
class Policies>
57 Policies
const &policies) {
58 typedef Eigen::Ref<const MatrixType> ConstRefType;
59 return bp::make_function(
60 internal::eigen_member<MatrixType, C>(v), policies,
61 boost::mpl::vector3<void, C &, const ConstRefType>());
64template <
class C,
class MatrixType>
bp::object make_setter_eigen_matrix(MatrixType C::*v, Policies const &policies)
bp::object make_getter_eigen_matrix(MatrixType C::*v)
Create a getter for Eigen::Matrix type objects which returns an Eigen::Ref.