6 #include "knowrob/Logger.h"
7 #include "knowrob/reasoner/Reasoner.h"
8 #include "knowrob/reasoner/ReasonerManager.h"
9 #include "knowrob/reasoner/ReasonerError.h"
10 #include "knowrob/reasoner/GoalDrivenReasoner.h"
11 #include "knowrob/reasoner/DataDrivenReasoner.h"
12 #include "knowrob/integration/python/utils.h"
17 reasonerManager_(nullptr),
20 static const auto undefinedName = std::make_shared<Atom>(
"undefined");
21 t_reasonerName_ = undefinedName;
25 if (reasonerManager_) {
26 return *reasonerManager_;
28 throw ReasonerError(
"No ReasonerManager has been assigned to the reasoner.");
35 explicit ReasonerTask(
const std::function<
void()> &fn) : fn_(fn) {}
37 void run()
override { fn_(); }
45 auto runner = std::make_shared<ReasonerTask>(fn);
47 KB_ERROR(
"Error in reasoner worker thread: {}", e.what());
53 struct ReasonerWrap :
public Reasoner, boost::python::wrapper<Reasoner> {
54 explicit ReasonerWrap(PyObject *p) :
Reasoner(), self(p) {}
56 bool initializeReasoner(
const PropertyTree &config)
override {
57 return call_method<bool>(
self,
"initializeReasoner", config);
67 class_<Reasoner, std::shared_ptr<ReasonerWrap>, bases<DataSourceHandler>, boost::noncopyable>
68 (
"Reasoner", init<>())
69 .def(
"pushWork", +[](
Reasoner &x,
object &fn) {
70 auto fn_wrap = std::make_shared<PyObj_wrap>(fn);
78 .def(
"initializeReasoner", &ReasonerWrap::initializeReasoner);
void pushWork(const std::function< void(void)> &fn)
ReasonerManager & reasonerManager() const
auto reasonerLanguage() const
FunctionRule & function()
void createType< GoalDrivenReasoner >()
void createType< Reasoner >()
void createType< DataDrivenReasoner >()
std::shared_ptr< ThreadPool > DefaultThreadPool()
int run(int argc, char **argv)