6 #ifndef KNOWROB_PLUGIN_MODULE_H_
7 #define KNOWROB_PLUGIN_MODULE_H_
13 #include <boost/python.hpp>
14 #include "knowrob/plugins/PluginFactory.h"
15 #include "knowrob/integration/python/utils.h"
16 #include "knowrob/Logger.h"
24 class PluginModule :
public PluginFactory<T> {
30 PluginModule(std::string_view modulePath, std::string_view pluginType)
48 return knowrob::py::call_with_gil<bool>([&] {
71 if (!std::filesystem::exists(modulePath)) {
81 pyModule_ = boost::python::import(importString.c_str());
87 }
catch (
const boost::python::error_already_set &) {
94 std::shared_ptr<NamedPlugin<T>>
create(std::string_view pluginID)
override {
99 boost::python::extract<std::shared_ptr<T>> extracted(pyReasoner);
100 if (extracted.check()) {
105 }
catch (
const boost::python::error_already_set &) {
PluginModule(std::string_view modulePath, std::string_view pluginType)
PluginModule(const PluginModule &)=delete
boost::python::object pyModule_
std::shared_ptr< NamedPlugin< T > > create(std::string_view pluginID) override
const std::string pluginType_
const std::string modulePath_
boost::python::object pyPluginType_
std::string_view name() const override
std::string addToSysPath(const std::filesystem::path &modulePath)
std::string resolveModulePath(std::string_view modulePath)