pinocchio 4.1.0
A fast and flexible implementation of Rigid Body Dynamics algorithms and their analytical derivatives
Loading...
Searching...
No Matches
pickle-vector.hpp
1//
2// Copyright (c) 2019-2020 CNRS INRIA
3//
4
5#pragma once
6
7#include <boost/python.hpp>
8#include <boost/python/tuple.hpp>
9#include <boost/python/stl_iterator.hpp>
10
11namespace pinocchio
12{
13 namespace python
14 {
20 template<typename VecType>
21 struct PickleVector : boost::python::pickle_suite
22 {
23 static boost::python::tuple getinitargs(const VecType &)
24 {
25 return boost::python::make_tuple();
26 }
27
28 static boost::python::tuple getstate(boost::python::object op)
29 {
30 return boost::python::make_tuple(
31 boost::python::list(boost::python::extract<const VecType &>(op)()));
32 }
33
34 static void setstate(boost::python::object op, boost::python::tuple tup)
35 {
36 if (boost::python::len(tup) > 0)
37 {
38 VecType & o = boost::python::extract<VecType &>(op)();
39 boost::python::stl_input_iterator<typename VecType::value_type> begin(tup[0]), end;
40 while (begin != end)
41 {
42 o.push_back(*begin);
43 ++begin;
44 }
45 }
46 }
47
48 static bool getstate_manages_dict()
49 {
50 return true;
51 }
52 };
53 } // namespace python
54} // namespace pinocchio
Main pinocchio namespace.
Definition treeview.dox:11
Create a pickle interface for the std::vector and aligned vector.