knowrob
2.1.0
A Knowledge Base System for Cognition-enabled Robots
|
#include <PrologReasoner.h>
Public Member Functions | |
PrologReasoner () | |
~PrologReasoner () override | |
PrologReasoner (const PrologReasoner &)=delete | |
bool | setReasonerSetting (const TermPtr &key, const TermPtr &valueString) |
bool | consult (const std::filesystem::path &uri, const char *module={}, bool doTransformQuery=true) |
bool | load_rdf_xml (const std::filesystem::path &rdfFile) |
virtual std::string_view | callFunctor () |
PrologTerm | transformGoal (const PrologTerm &goal) |
std::list< TermPtr > | runTests (const std::string &target) |
bool | initializeReasoner (const PropertyTree &cfg) override |
bool | evaluate (GoalPtr query) override |
void | unload () override |
PrologReasoner () | |
~PrologReasoner () override | |
PrologReasoner (const PrologReasoner &)=delete | |
bool | setReasonerSetting (const TermPtr &key, const TermPtr &valueString) |
bool | consult (const std::filesystem::path &uri, const char *module={}, bool doTransformQuery=true) |
bool | load_rdf_xml (const std::filesystem::path &rdfFile) |
virtual std::string_view | callFunctor () |
PrologTerm | transformGoal (const PrologTerm &goal) |
std::list< TermPtr > | runTests (const std::string &target) |
bool | initializeReasoner (const PropertyTree &cfg) override |
bool | evaluate (GoalPtr query) override |
void | unload () override |
Public Member Functions inherited from knowrob::GoalDrivenReasoner | |
GoalDrivenReasoner () | |
bool | hasFeature (GoalDrivenReasonerFeature feature) const |
void | enableFeature (GoalDrivenReasonerFeature feature) |
bool | isRelationDefined (const PredicateIndicator &indicator) |
bool | isClassDefined (const std::string_view &iri) |
void | defineRelation (const PredicateIndicator &indicator) |
void | defineRelation (const IRIAtomPtr &iri) |
void | undefineRelation (const PredicateIndicator &indicator) |
void | defineClass (const IRIAtomPtr &iri) |
void | undefineClass (const IRIAtomPtr &iri) |
const auto & | definedRelations () const |
const auto & | definedClasses () const |
GoalDrivenReasoner () | |
bool | hasFeature (GoalDrivenReasonerFeature feature) const |
void | enableFeature (GoalDrivenReasonerFeature feature) |
bool | isRelationDefined (const PredicateIndicator &indicator) |
bool | isClassDefined (const std::string_view &iri) |
void | defineRelation (const PredicateIndicator &indicator) |
void | defineRelation (const IRIAtomPtr &iri) |
void | undefineRelation (const PredicateIndicator &indicator) |
void | defineClass (const IRIAtomPtr &iri) |
void | undefineClass (const IRIAtomPtr &iri) |
const auto & | definedRelations () const |
const auto & | definedClasses () const |
Public Member Functions inherited from knowrob::Reasoner | |
Reasoner () | |
virtual | ~Reasoner ()=default |
auto & | reasonerName () const |
auto | reasonerLanguage () const |
auto | storage () const |
template<class T > | |
std::shared_ptr< T > | getTypedStorage () const |
ReasonerManager & | reasonerManager () const |
void | pushWork (const std::function< void(void)> &fn) |
void | setStorage (const StoragePtr &storage) |
Reasoner () | |
virtual | ~Reasoner ()=default |
auto & | reasonerName () const |
auto | reasonerLanguage () const |
auto | storage () const |
template<class T > | |
std::shared_ptr< T > | getTypedStorage () const |
ReasonerManager & | reasonerManager () const |
void | pushWork (const std::function< void(void)> &fn) |
void | setStorage (const StoragePtr &storage) |
Public Member Functions inherited from knowrob::DataSourceHandler | |
DataSourceHandler ()=default | |
virtual | ~DataSourceHandler ()=default |
void | addDataHandler (const std::string &format, const DataSourceLoader &fn) |
bool | loadDataSource (const DataSourcePtr &dataSource) |
bool | hasDataHandler (const DataSourcePtr &dataSource) const |
DataSourceHandler ()=default | |
virtual | ~DataSourceHandler ()=default |
void | addDataHandler (const std::string &format, const DataSourceLoader &fn) |
bool | loadDataSource (const DataSourcePtr &dataSource) |
bool | hasDataHandler (const DataSourcePtr &dataSource) const |
Static Public Member Functions | |
static std::shared_ptr< NamedReasoner > | getDefinedReasoner (const term_t &t_reasonerManager, const term_t &t_reasonerModule) |
static std::shared_ptr< NamedReasoner > | getDefinedReasoner (const term_t &t_reasonerManager, const term_t &t_reasonerModule) |
Protected Member Functions | |
virtual bool | initializeGlobalPackages () |
virtual bool | initializeDefaultPackages () |
virtual void | initializeReasonerStorage () |
bool | loadDataSourceWithUnknownFormat (const DataSourcePtr &dataFile) override |
AnswerYesPtr | yes (const GoalPtr &query, const PrologTerm &rdfGoal, const PrologTerm &frameTerm) |
AnswerNoPtr | no (const GoalPtr &query) |
PrologTerm | getReasonerQuery (const PrologTerm &goal) |
virtual bool | initializeGlobalPackages () |
virtual bool | initializeDefaultPackages () |
virtual void | initializeReasonerStorage () |
bool | loadDataSourceWithUnknownFormat (const DataSourcePtr &dataFile) override |
AnswerYesPtr | yes (const GoalPtr &query, const PrologTerm &rdfGoal, const PrologTerm &frameTerm) |
AnswerNoPtr | no (const GoalPtr &query) |
PrologTerm | getReasonerQuery (const PrologTerm &goal) |
Static Protected Member Functions | |
static bool | putQueryFrame (PrologTerm &frameTerm, const GraphSelector &frame) |
static std::shared_ptr< GraphSelector > | createAnswerFrame (const PrologTerm &plTerm) |
static bool | putQueryFrame (PrologTerm &frameTerm, const GraphSelector &frame) |
static std::shared_ptr< GraphSelector > | createAnswerFrame (const PrologTerm &plTerm) |
Protected Attributes | |
std::shared_ptr< PrologBackend > | knowledgeGraph_ |
Protected Attributes inherited from knowrob::GoalDrivenReasoner | |
std::set< PredicateIndicator > | definedRelations_ |
std::set< PredicateIndicator > | definedClasses_ |
int | features_ |
Protected Attributes inherited from knowrob::DataSourceHandler | |
std::map< std::string, DataSourceLoader > | dataSourceHandler_ |
Static Protected Attributes | |
static bool | isKnowRobInitialized_ = false |
A Prolog reasoner that answers queries using SWI Prolog.
Definition at line 30 of file PrologReasoner.h.
PrologReasoner::PrologReasoner | ( | ) |
Definition at line 84 of file PrologReasoner.cpp.
|
overridedefault |
|
delete |
Cannot be copy-assigned.
knowrob::PrologReasoner::PrologReasoner | ( | ) |
|
override |
|
delete |
Cannot be copy-assigned.
|
virtual |
Reimplemented in knowrob::MongologReasoner, and knowrob::MongologReasoner.
Definition at line 100 of file PrologReasoner.cpp.
|
virtual |
Reimplemented in knowrob::MongologReasoner, and knowrob::MongologReasoner.
bool PrologReasoner::consult | ( | const std::filesystem::path & | uri, |
const char * | module = {} , |
||
bool | doTransformQuery = true |
||
) |
Consults a Prolog file, i.e. loads facts and rules and executed directives in the file. May throw an exception if there is no valid Prolog file at the given path.
uri | the local path to the file. |
module | the module to consult the file into. |
doTransformQuery | if true, then the file is transformed into a query. |
Definition at line 187 of file PrologReasoner.cpp.
bool knowrob::PrologReasoner::consult | ( | const std::filesystem::path & | uri, |
const char * | module = {} , |
||
bool | doTransformQuery = true |
||
) |
Consults a Prolog file, i.e. loads facts and rules and executed directives in the file. May throw an exception if there is no valid Prolog file at the given path.
uri | the local path to the file. |
module | the module to consult the file into. |
doTransformQuery | if true, then the file is transformed into a query. |
|
staticprotected |
Definition at line 377 of file PrologReasoner.cpp.
|
staticprotected |
|
overridevirtual |
Evaluate a query with a reasoner. The query is represented by a formula, a context and an answer queue where results of the reasoning process can be added. The evaluation of the query must be performed synchronously, i.e. the answer queue must be filled before the function returns. A reasoner may instead throw an exception if the query cannot be evaluated, or return false to also indicate an error status.
query | the query to evaluate. |
Implements knowrob::GoalDrivenReasoner.
Definition at line 204 of file PrologReasoner.cpp.
|
overridevirtual |
Evaluate a query with a reasoner. The query is represented by a formula, a context and an answer queue where results of the reasoning process can be added. The evaluation of the query must be performed synchronously, i.e. the answer queue must be filled before the function returns. A reasoner may instead throw an exception if the query cannot be evaluated, or return false to also indicate an error status.
query | the query to evaluate. |
Implements knowrob::GoalDrivenReasoner.
|
static |
Definition at line 167 of file PrologReasoner.cpp.
|
static |
|
protected |
Definition at line 157 of file PrologReasoner.cpp.
|
protected |
|
inlineprotectedvirtual |
Reimplemented in knowrob::SWRLReasoner, knowrob::MongologReasoner, knowrob::ESGReasoner, knowrob::SWRLReasoner, knowrob::MongologReasoner, and knowrob::ESGReasoner.
Definition at line 91 of file PrologReasoner.h.
|
inlineprotectedvirtual |
Reimplemented in knowrob::SWRLReasoner, knowrob::MongologReasoner, knowrob::ESGReasoner, knowrob::SWRLReasoner, knowrob::MongologReasoner, and knowrob::ESGReasoner.
Definition at line 91 of file PrologReasoner.h.
|
inlineprotectedvirtual |
Definition at line 89 of file PrologReasoner.h.
|
inlineprotectedvirtual |
Definition at line 89 of file PrologReasoner.h.
|
overridevirtual |
Initialize a reasoner by configuring it with a property tree.
ptree | a PropertyTree object. |
Implements knowrob::Reasoner.
Reimplemented in knowrob::MongologReasoner.
Definition at line 109 of file PrologReasoner.cpp.
|
overridevirtual |
Initialize a reasoner by configuring it with a property tree.
ptree | a PropertyTree object. |
Implements knowrob::Reasoner.
|
inlineprotectedvirtual |
Reimplemented in knowrob::MongologReasoner, and knowrob::MongologReasoner.
Definition at line 93 of file PrologReasoner.h.
|
inlineprotectedvirtual |
Reimplemented in knowrob::MongologReasoner, and knowrob::MongologReasoner.
Definition at line 93 of file PrologReasoner.h.
bool PrologReasoner::load_rdf_xml | ( | const std::filesystem::path & | rdfFile | ) |
rdfFile | a rdf-xml encoded file. |
Definition at line 198 of file PrologReasoner.cpp.
bool knowrob::PrologReasoner::load_rdf_xml | ( | const std::filesystem::path & | rdfFile | ) |
rdfFile | a rdf-xml encoded file. |
|
inlineoverrideprotectedvirtual |
Reimplemented from knowrob::DataSourceHandler.
Definition at line 95 of file PrologReasoner.h.
|
inlineoverrideprotectedvirtual |
Reimplemented from knowrob::DataSourceHandler.
Definition at line 95 of file PrologReasoner.h.
|
protected |
Definition at line 291 of file PrologReasoner.cpp.
|
protected |
|
staticprotected |
Definition at line 316 of file PrologReasoner.cpp.
|
staticprotected |
std::list< TermPtr > PrologReasoner::runTests | ( | const std::string & | target | ) |
Definition at line 457 of file PrologReasoner.cpp.
std::list<TermPtr> knowrob::PrologReasoner::runTests | ( | const std::string & | target | ) |
bool knowrob::PrologReasoner::setReasonerSetting | ( | const TermPtr & | key, |
const TermPtr & | valueString | ||
) |
key | |
valueString |
PrologTerm PrologReasoner::transformGoal | ( | const PrologTerm & | goal | ) |
Definition at line 105 of file PrologReasoner.cpp.
PrologTerm knowrob::PrologReasoner::transformGoal | ( | const PrologTerm & | goal | ) |
|
overridevirtual |
Unload the reasoner, meaning that all static resources associated to this reasoner are released.
Reimplemented from knowrob::Reasoner.
Reimplemented in knowrob::SWRLReasoner, knowrob::MongologReasoner, and knowrob::SWRLReasoner.
Definition at line 95 of file PrologReasoner.cpp.
|
overridevirtual |
Unload the reasoner, meaning that all static resources associated to this reasoner are released.
Reimplemented from knowrob::Reasoner.
Reimplemented in knowrob::SWRLReasoner.
|
protected |
Definition at line 252 of file PrologReasoner.cpp.
|
protected |
|
staticprotected |
Definition at line 86 of file PrologReasoner.h.
|
protected |
Definition at line 87 of file PrologReasoner.h.