std-aligned-vector.hpp
Go to the documentation of this file.
1 //
2 // Copyright (c) 2016-2024 CNRS INRIA
3 //
4 
5 #ifndef __pinocchio_python_utils_std_aligned_vector_hpp__
6 #define __pinocchio_python_utils_std_aligned_vector_hpp__
7 
8 #include <boost/python.hpp>
9 #include <string>
10 
12 
15 
16 namespace pinocchio
17 {
18  namespace python
19  {
20 
30  template<class T, bool NoProxy = false, bool EnableFromPythonListConverter = true>
32  : public ::boost::python::vector_indexing_suite<
33  typename container::aligned_vector<T>,
34  NoProxy,
35  eigenpy::internal::
36  contains_vector_derived_policies<typename container::aligned_vector<T>, NoProxy>>
37  , public eigenpy::StdContainerFromPythonList<container::aligned_vector<T>>
38  {
41  typedef T value_type;
42 
43  static void expose(const std::string & class_name, const std::string & doc_string = "")
44  {
45  expose(class_name, doc_string, eigenpy::EmptyPythonVisitor());
46  }
47 
48  template<typename VisitorDerived>
49  static void expose(
50  const std::string & class_name, const boost::python::def_visitor<VisitorDerived> & visitor)
51  {
52  expose(class_name, "", visitor);
53  }
54 
55  template<typename VisitorDerived>
56  static void expose(
57  const std::string & class_name,
58  const std::string & doc_string,
59  const boost::python::def_visitor<VisitorDerived> & visitor)
60  {
61  namespace bp = boost::python;
62  if (!eigenpy::register_symbolic_link_to_registered_type<vector_type>())
63  {
64  bp::class_<vector_type> cl(class_name.c_str(), doc_string.c_str());
66 
67  .def(bp::init<size_t, const value_type &>(
68  bp::args("self", "size", "value"),
69  "Constructor from a given size and a given value."))
70  .def(bp::init<const vector_type &>(bp::args("self", "other"), "Copy constructor"))
71 
72  .def(
74  (bp::arg("self"), bp::arg("deep_copy") = false),
75  "Returns the aligned_vector as a Python list.")
76  .def(visitor)
77 #ifndef PINOCCHIO_PYTHON_NO_SERIALIZATION
78  .def_pickle(PickleVector<vector_type>())
79 #endif
81 
82  // Register conversion
83  if (EnableFromPythonListConverter)
85  }
86  }
87  };
88  } // namespace python
89 } // namespace pinocchio
90 
91 #endif // ifndef __pinocchio_python_utils_std_aligned_vector_hpp__
eigenpy::CopyableVisitor
boost::python
aligned-vector.hpp
pinocchio::python::StdAlignedVectorPythonVisitor::expose
static void expose(const std::string &class_name, const std::string &doc_string, const boost::python::def_visitor< VisitorDerived > &visitor)
Definition: std-aligned-vector.hpp:56
eigenpy::StdContainerFromPythonList
eigenpy::StdContainerFromPythonList::register_converter
static void register_converter()
eigenpy::EmptyPythonVisitor
python
pickle-vector.hpp
pinocchio::python::StdAlignedVectorPythonVisitor::FromPythonListConverter
eigenpy::StdContainerFromPythonList< vector_type, NoProxy > FromPythonListConverter
Definition: std-aligned-vector.hpp:40
eigenpy::StdContainerFromPythonList::tolist
::boost::python::list tolist(vector_type &self, const bool deep_copy=false)
pinocchio::python::StdAlignedVectorPythonVisitor::expose
static void expose(const std::string &class_name, const std::string &doc_string="")
Definition: std-aligned-vector.hpp:43
pinocchio::python::StdAlignedVectorPythonVisitor::expose
static void expose(const std::string &class_name, const boost::python::def_visitor< VisitorDerived > &visitor)
Definition: std-aligned-vector.hpp:49
pinocchio::python::StdAlignedVectorPythonVisitor::vector_type
container::aligned_vector< T > vector_type
Definition: std-aligned-vector.hpp:39
pinocchio::container::aligned_vector
std::vector< T, Eigen::aligned_allocator< T > > aligned_vector
Definition: container/aligned-vector.hpp:21
eigenpy::StdContainerFromPythonList< container::aligned_vector< T > >::T
vector_type::value_type T
cl
cl
pinocchio::python::StdAlignedVectorPythonVisitor
Expose an container::aligned_vector from a type given as template argument.
Definition: std-aligned-vector.hpp:31
std-vector.hpp
pinocchio::python::StdAlignedVectorPythonVisitor::value_type
T value_type
Definition: std-aligned-vector.hpp:41
pinocchio
Main pinocchio namespace.
Definition: timings.cpp:27
pinocchio::python::PickleVector
Create a pickle interface for the std::vector and aligned vector.
Definition: pickle-vector.hpp:22


pinocchio
Author(s):
autogenerated on Sun Dec 22 2024 03:41:12