34#include <boost/python.hpp>
35#include <eigenpy/eigenpy.hpp>
39#define INIT_PYHPP_MODULE \
40 boost::python::docstring_options local_docstring_options(true, true, false)
42#define PYHPP_DEFINE_METHOD(CLASS, METHOD) def(#METHOD, &CLASS::METHOD)
43#define PYHPP_DEFINE_METHOD1(CLASS, METHOD, ARG1) \
44 def(#METHOD, &CLASS::METHOD, ARG1)
45#define PYHPP_DEFINE_METHOD2(CLASS, METHOD, ARG1, ARG2) \
46 def(#METHOD, &CLASS::METHOD, ARG1, ARG2)
47#define PYHPP_DEFINE_METHOD_INTERNAL_REF(CLASS, METHOD) \
48 def(#METHOD, &CLASS::METHOD, return_internal_reference<>())
49#define PYHPP_DEFINE_METHOD_CONST_REF(CLASS, METHOD) \
50 def(#METHOD, &CLASS::METHOD, return_value_policy<copy_const_reference>())
51#define PYHPP_DEFINE_METHOD_CONST_REF_BY_VALUE(CLASS, METHOD) \
52 def(#METHOD, &CLASS::METHOD, return_value_policy<return_by_value>())
53#define PYHPP_DEFINE_GETTER_SETTER(CLASS, METHOD, TYPE) \
54 def(#METHOD, static_cast<TYPE (CLASS::*)() const>(&CLASS::METHOD)) \
55 .def(#METHOD, static_cast<void (CLASS::*)(TYPE)>(&CLASS::METHOD))
56#define PYHPP_DEFINE_GETTER_SETTER_INTERNAL_REF(CLASS, METHOD, TYPE) \
57 def(#METHOD, static_cast<TYPE (CLASS::*)() const>(&CLASS::METHOD), \
58 return_internal_reference<>()) \
59 .def(#METHOD, static_cast<void (CLASS::*)(TYPE)>(&CLASS::METHOD))
60#define PYHPP_DEFINE_GETTER_SETTER_CONST_REF(CLASS, METHOD, TYPE) \
61 def(#METHOD, static_cast<TYPE (CLASS::*)() const>(&CLASS::METHOD)) \
62 .def(#METHOD, static_cast<void (CLASS::*)(const TYPE&)>(&CLASS::METHOD))
63#define PYHPP_DEFINE_METHOD_STATIC(CLASS, METHOD) \
64 def(#METHOD, &CLASS::METHOD).staticmethod(#METHOD)
67template <
typename ObjectWithPr
intMethod>
68std::string
to_str(
const ObjectWithPrintMethod& obj) {
69 std::ostringstream oss;
73template <
typename ObjectWithPr
intMethod>
75 std::ostringstream oss;
80template <
typename T,
typename _Vector = std::vector<hpp::shared_ptr<T> > >
84 if (i > v.size())
throw std::invalid_argument(
"Out of range");
85 if (!v[i])
throw std::runtime_error(
"Null pointer");
92 return std::vector<T>(boost::python::stl_input_iterator<T>(py_list),
93 boost::python::stl_input_iterator<T>());
97 boost::python::list py_list;
98 for (
const auto& item : vec) {
std::string to_str(const ObjectWithPrintMethod &obj)
Definition: util.hh:68
std::string to_str_from_operator(const ObjectWithPrintMethod &obj)
Definition: util.hh:74
boost::python::list to_python_list(const std::vector< T > &vec)
Definition: util.hh:96
std::vector< T > extract_vector(boost::python::list py_list)
Definition: util.hh:91
_Vector Vector
Definition: util.hh:82
static T & get_item(Vector &v, std::size_t i)
Definition: util.hh:83