6 #ifndef KNOWROB_REASONER_H_
7 #define KNOWROB_REASONER_H_
10 #include "knowrob/PropertyTree.h"
11 #include "knowrob/terms/Atom.h"
12 #include "knowrob/DataSource.h"
13 #include "knowrob/DataSourceHandler.h"
14 #include "knowrob/storage/Storage.h"
15 #include "knowrob/plugins/NamedPlugin.h"
20 class ReasonerManager;
28 class Reasoner :
public DataSourceHandler {
53 auto typed = std::dynamic_pointer_cast<T>(storage_);
54 if (!typed)
throw ReasonerError(
"Storage is not of the expected type.");
95 void setReasonerName(std::string_view name) { t_reasonerName_ =
Atom::Tabled(name); }
97 void setReasonerLanguage(
PluginLanguage lang) { reasonerLanguage_ = lang; }
117 #define REASONER_PLUGIN(classType, pluginName) extern "C" { \
118 std::shared_ptr<knowrob::Reasoner> knowrob_createPlugin(std::string_view pluginID) \
119 { return std::make_shared<classType>(pluginID); } \
120 const char* knowrob_getPluginName() { return pluginName; } }
static std::shared_ptr< knowrob::Atom > Tabled(std::string_view stringForm)
friend class ReasonerManager
ReasonerManager & reasonerManager() const
ReasonerManager & reasonerManager() const
std::shared_ptr< T > getTypedStorage() const
virtual bool initializeReasoner(const PropertyTree &ptree)=0
void setStorage(const StoragePtr &storage)
auto & reasonerName() const
void pushWork(const std::function< void(void)> &fn)
auto reasonerLanguage() const
virtual ~Reasoner()=default
FunctionRule & function()
std::shared_ptr< Reasoner > ReasonerPtr
PluginFactory< Reasoner > ReasonerFactory
std::shared_ptr< Atom > AtomPtr
NamedPlugin< Reasoner > NamedReasoner
std::shared_ptr< Storage > StoragePtr