namespaces_pybind.cpp
Go to the documentation of this file.
1 
2 
3 #include <pybind11/eigen.h>
4 #include <pybind11/stl_bind.h>
5 #include <pybind11/pybind11.h>
6 #include <pybind11/operators.h>
7 #include "gtsam/nonlinear/utilities.h" // for RedirectCout.
8 
9 #include "path/to/ns1.h"
10 #include "path/to/ns1/ClassB.h"
11 #include "path/to/ns2.h"
12 #include "path/to/ns2/ClassA.h"
13 #include "path/to/ns3.h"
14 
15 #include "wrap/serialization.h"
16 #include <boost/serialization/export.hpp>
17 
18 
19 
20 
21 
22 using namespace std;
23 
24 namespace py = pybind11;
25 
26 PYBIND11_MODULE(namespaces_py, m_) {
27  m_.doc() = "pybind11 wrapper of namespaces_py";
28 
29  pybind11::module m_ns1 = m_.def_submodule("ns1", "ns1 submodule");
30 
31  py::class_<ns1::ClassA, std::shared_ptr<ns1::ClassA>>(m_ns1, "ClassA")
32  .def(py::init<>());
33 
34  py::class_<ns1::ClassB, std::shared_ptr<ns1::ClassB>>(m_ns1, "ClassB")
35  .def(py::init<>());
36 
37  m_ns1.def("aGlobalFunction",[](){return ns1::aGlobalFunction();}); pybind11::module m_ns2 = m_.def_submodule("ns2", "ns2 submodule");
38 
39  py::class_<ns2::ClassA, std::shared_ptr<ns2::ClassA>>(m_ns2, "ClassA")
40  .def(py::init<>())
41  .def("memberFunction",[](ns2::ClassA* self){return self->memberFunction();})
42  .def("nsArg",[](ns2::ClassA* self, const ns1::ClassB& arg){return self->nsArg(arg);}, py::arg("arg"))
43  .def("nsReturn",[](ns2::ClassA* self, double q){return self->nsReturn(q);}, py::arg("q"))
44  .def_static("afunction",[](){return ns2::ClassA::afunction();});
45  pybind11::module m_ns2_ns3 = m_ns2.def_submodule("ns3", "ns3 submodule");
46 
47  py::class_<ns2::ns3::ClassB, std::shared_ptr<ns2::ns3::ClassB>>(m_ns2_ns3, "ClassB")
48  .def(py::init<>());
49 
50  py::class_<ns2::ClassC, std::shared_ptr<ns2::ClassC>>(m_ns2, "ClassC")
51  .def(py::init<>());
52 
53  m_ns2.attr("aNs2Var") = ns2::aNs2Var;
54  m_ns2.def("aGlobalFunction",[](){return ns2::aGlobalFunction();});
55  m_ns2.def("overloadedGlobalFunction",[](const ns1::ClassA& a){return ns2::overloadedGlobalFunction(a);}, py::arg("a"));
56  m_ns2.def("overloadedGlobalFunction",[](const ns1::ClassA& a, double b){return ns2::overloadedGlobalFunction(a, b);}, py::arg("a"), py::arg("b"));
57  py::class_<ClassD, std::shared_ptr<ClassD>>(m_, "ClassD")
58  .def(py::init<>());
59 
60  m_.attr("aGlobalVar") = aGlobalVar;
61 
62 #include "python/specializations.h"
63 
64 }
65 
module_ module
Definition: pybind11.h:943
Scalar * b
Definition: benchVecAdd.cpp:17
module_ def_submodule(const char *name, const char *doc=nullptr)
Definition: pybind11.h:903
Definition: Half.h:150
Definition: cast.h:1853
module_ & def(const char *name_, Func &&f, const Extra &...extra)
Definition: pybind11.h:884
Array33i a
EIGEN_DEVICE_FUNC const Scalar & q
PYBIND11_MODULE(namespaces_py, m_)
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const ArgReturnType arg() const


gtsam
Author(s):
autogenerated on Sat May 8 2021 02:43:02