8 #include <pybind11/pybind11.h>
9 #include <pybind11/stl.h>
12 #include <nap/resource.h>
13 #include <nap/logger.h>
14 #include <rtti/factory.h>
15 #include <utility/errorstate.h>
21 class PythonScriptService;
45 template <
typename ReturnType,
typename ...Args>
46 bool get(
const std::string& identifier,
utility::ErrorState& errorState, ReturnType& returnValue, Args&&... args);
55 template <
typename ...Args>
62 pybind11::object get(
const std::string& symbol);
65 pybind11::module mModule;
70 template <
typename ReturnType,
typename ...Args>
75 returnValue = mModule.attr(identifier.c_str())(std::forward<Args>(args)...).template cast<ReturnType>();
77 catch (
const pybind11::error_already_set& err)
79 errorState.
fail(
"Runtime python error while executing %s: %s",
mPath.c_str(), err.what());
86 template <
typename ...Args>
91 mModule.attr(identifier.c_str())(std::forward<Args>(args)...);
93 catch (
const pybind11::error_already_set& err)
95 errorState.
fail(
"Runtime python error while executing %s: %s",
mPath.c_str(), err.what());