pickle-vector.hpp
Go to the documentation of this file.
1 //
2 // Copyright (c) 2019-2020 CNRS INRIA
3 //
4 
5 #ifndef __pinocchio_python_utils_pickle_vector_hpp__
6 #define __pinocchio_python_utils_pickle_vector_hpp__
7 
8 #include <boost/python.hpp>
9 #include <boost/python/tuple.hpp>
10 #include <boost/python/stl_iterator.hpp>
11 
12 namespace pinocchio
13 {
14  namespace python
15  {
21  template<typename VecType>
22  struct PickleVector : boost::python::pickle_suite
23  {
24  static boost::python::tuple getinitargs(const VecType&)
25  { return boost::python::make_tuple(); }
26 
27  static boost::python::tuple getstate(boost::python::object op)
28  {
29  return boost::python::make_tuple(boost::python::list(boost::python::extract<const VecType&>(op)()));
30  }
31 
32  static void setstate(boost::python::object op, boost::python::tuple tup)
33  {
34  if(boost::python::len(tup) > 0)
35  {
36  VecType & o = boost::python::extract<VecType&>(op)();
37  boost::python::stl_input_iterator<typename VecType::value_type> begin(tup[0]), end;
38  while(begin != end)
39  {
40  o.push_back(*begin);
41  ++begin;
42  }
43  }
44  }
45 
46  static bool getstate_manages_dict() { return true; }
47  };
48  }
49 }
50 
51 #endif // ifndef __pinocchio_python_utils_pickle_vector_hpp__
static void setstate(boost::python::object op, boost::python::tuple tup)
static boost::python::tuple getinitargs(const VecType &)
Create a pickle interface for the std::vector and aligned vector.
Main pinocchio namespace.
Definition: timings.cpp:28
static boost::python::tuple getstate(boost::python::object op)
Vec3f o


pinocchio
Author(s):
autogenerated on Fri Jun 23 2023 02:38:32