pinocchio  3.7.0
A fast and flexible implementation of Rigid Body Dynamics algorithms and their analytical derivatives
 
Loading...
Searching...
No Matches
namespace.hpp
1//
2// Copyright (c) 2019-2021 INRIA
3//
4
5#ifndef __pinocchio_python_utils_namespace_hpp__
6#define __pinocchio_python_utils_namespace_hpp__
7
8#include <boost/python.hpp>
9#include <string>
10
11namespace pinocchio
12{
13 namespace python
14 {
15
19 inline std::string getCurrentScopeName()
20 {
21 namespace bp = boost::python;
22 bp::scope current_scope;
23
24 return std::string(bp::extract<const char *>(current_scope.attr("__name__")));
25 }
26
34 inline boost::python::object getOrCreatePythonNamespace(const std::string & submodule_name)
35 {
36 namespace bp = boost::python;
37
38 const std::string complete_submodule_name = getCurrentScopeName() + "." + submodule_name;
39
40 bp::object submodule(bp::borrowed(PyImport_AddModule(complete_submodule_name.c_str())));
41 bp::scope current_scope;
42 current_scope.attr(submodule_name.c_str()) = submodule;
43
44 return submodule;
45 }
46 } // namespace python
47} // namespace pinocchio
48
49#endif // ifndef __pinocchio_python_utils_namespace_hpp__
Main pinocchio namespace.
Definition treeview.dox:11