aligator
0.10.0
A primal-dual augmented Lagrangian-type solver for nonlinear trajectory optimization.
Loading...
Searching...
No Matches
visitors.hpp
Go to the documentation of this file.
1
3
#pragma once
4
5
#include <eigenpy/fwd.hpp>
6
#include <fmt/format.h>
7
8
namespace
aligator
{
9
namespace
python {
10
namespace
bp
=
boost::python
;
11
12
// fwd-declaration
13
bp::arg
operator
""
_a(
const
char
*argname, std::size_t);
14
15
template
<
typename
T>
16
struct
ClonePythonVisitor
: bp::def_visitor<ClonePythonVisitor<T>> {
17
template
<
typename
PyT>
void
visit
(PyT &obj)
const
{
18
obj.def(
"clone"
, &T::clone, bp::args(
"self"
),
"Clone the object."
);
19
}
20
};
21
22
template
<
typename
T>
23
struct
CreateDataPythonVisitor
: bp::def_visitor<CreateDataPythonVisitor<T>> {
24
template
<
typename
Py
class
>
void
visit
(Pyclass &obj)
const
{
25
obj.def(
"createData"
, &T::createData, bp::args(
"self"
),
26
"Create a data object."
);
27
}
28
};
29
36
template
<
typename
T,
typename
TWrapper>
37
struct
CreateDataPolymorphicPythonVisitor
38
: bp::def_visitor<CreateDataPolymorphicPythonVisitor<T, TWrapper>> {
39
template
<
typename
PyClass>
void
visit
(PyClass &obj)
const
{
40
obj.def(
"createData"
, &T::createData, &TWrapper::default_createData,
41
bp::args(
"self"
),
"Create a data object."
);
42
}
43
};
44
45
template
<
typename
T>
46
struct
CopyableVisitor
: bp::def_visitor<CopyableVisitor<T>> {
47
template
<
typename
PyClass>
void
visit
(PyClass &obj)
const
{
48
obj.def(
"copy"
, ©, bp::arg(
"self"
),
"Returns a copy of this."
);
49
}
50
51
private
:
52
static
T copy(
const
T &self) {
return
T(self); }
53
};
54
55
template
<
typename
T>
56
struct
PrintableVisitor
: bp::def_visitor<PrintableVisitor<T>> {
57
template
<
typename
PyClass>
void
visit
(PyClass &obj)
const
{
58
obj.def(bp::self_ns::str(bp::self)).def(bp::self_ns::repr(bp::self));
59
}
60
};
61
62
template
<
typename
T>
63
struct
PrintAddressVisitor
: bp::def_visitor<PrintAddressVisitor<T>> {
64
template
<
typename
PyClass>
void
visit
(PyClass &obj)
const
{
65
obj.def(
"printAddress"
,
printAddress
, bp::args(
"self"
));
66
}
67
static
void
*
getAddress
(
const
T &a) {
return
(
void
*)&a; }
68
static
void
printAddress
(
const
T &a) {
69
fmt::print(
"Address: {:p}\n"
,
getAddress
(a));
70
}
71
};
72
73
// fwd declaration
74
template
<
typename
SolverType>
struct
SolverVisitor
;
75
76
}
// namespace python
77
}
// namespace aligator
aligator
Main package namespace.
Definition
action-model-wrap.hpp:14
boost::python
Definition
costs.hpp:46
aligator::python::ClonePythonVisitor
Definition
visitors.hpp:16
aligator::python::ClonePythonVisitor::visit
void visit(PyT &obj) const
Definition
visitors.hpp:17
aligator::python::CopyableVisitor
Definition
visitors.hpp:46
aligator::python::CopyableVisitor::visit
void visit(PyClass &obj) const
Definition
visitors.hpp:47
aligator::python::CreateDataPolymorphicPythonVisitor
Definition
visitors.hpp:38
aligator::python::CreateDataPolymorphicPythonVisitor::visit
void visit(PyClass &obj) const
Definition
visitors.hpp:39
aligator::python::CreateDataPythonVisitor
Definition
visitors.hpp:23
aligator::python::CreateDataPythonVisitor::visit
void visit(Pyclass &obj) const
Definition
visitors.hpp:24
aligator::python::PrintAddressVisitor
Definition
visitors.hpp:63
aligator::python::PrintAddressVisitor::visit
void visit(PyClass &obj) const
Definition
visitors.hpp:64
aligator::python::PrintAddressVisitor::getAddress
static void * getAddress(const T &a)
Definition
visitors.hpp:67
aligator::python::PrintAddressVisitor::printAddress
static void printAddress(const T &a)
Definition
visitors.hpp:68
aligator::python::PrintableVisitor
Definition
visitors.hpp:56
aligator::python::PrintableVisitor::visit
void visit(PyClass &obj) const
Definition
visitors.hpp:57
aligator::python::SolverVisitor
Definition
visitors.hpp:74
bindings
python
include
aligator
python
visitors.hpp
Generated by
1.11.0