knowrob  2.1.0
A Knowledge Base System for Cognition-enabled Robots
knowrob::RDFGoalReasoner Class Referenceabstract

#include <RDFGoalReasoner.h>

Inheritance diagram for knowrob::RDFGoalReasoner:
Collaboration diagram for knowrob::RDFGoalReasoner:

Public Member Functions

 RDFGoalReasoner ()
 
virtual ~RDFGoalReasoner ()=default
 
virtual bool evaluate (RDFGoalPtr query)=0
 
bool evaluate (GoalPtr query) override
 
 RDFGoalReasoner ()
 
virtual ~RDFGoalReasoner ()=default
 
virtual bool evaluate (RDFGoalPtr query)=0
 
bool evaluate (GoalPtr query) 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
 
ReasonerManagerreasonerManager () const
 
void pushWork (const std::function< void(void)> &fn)
 
void setStorage (const StoragePtr &storage)
 
virtual bool initializeReasoner (const PropertyTree &ptree)=0
 
virtual void unload ()
 
 Reasoner ()
 
virtual ~Reasoner ()=default
 
auto & reasonerName () const
 
auto reasonerLanguage () const
 
auto storage () const
 
template<class T >
std::shared_ptr< T > getTypedStorage () const
 
ReasonerManagerreasonerManager () const
 
void pushWork (const std::function< void(void)> &fn)
 
void setStorage (const StoragePtr &storage)
 
virtual bool initializeReasoner (const PropertyTree &ptree)=0
 
virtual void unload ()
 
- 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
 

Additional Inherited Members

- Protected Member Functions inherited from knowrob::DataSourceHandler
virtual bool loadDataSourceWithUnknownFormat (const DataSourcePtr &)
 
virtual bool loadDataSourceWithUnknownFormat (const DataSourcePtr &)
 
- Protected Attributes inherited from knowrob::GoalDrivenReasoner
std::set< PredicateIndicatordefinedRelations_
 
std::set< PredicateIndicatordefinedClasses_
 
int features_
 
- Protected Attributes inherited from knowrob::DataSourceHandler
std::map< std::string, DataSourceLoaderdataSourceHandler_
 

Detailed Description

A reasoner that evaluates RDF goals.

Definition at line 16 of file RDFGoalReasoner.h.

Constructor & Destructor Documentation

◆ RDFGoalReasoner() [1/2]

knowrob::RDFGoalReasoner::RDFGoalReasoner ( )
inline

Definition at line 18 of file RDFGoalReasoner.h.

◆ ~RDFGoalReasoner() [1/2]

virtual knowrob::RDFGoalReasoner::~RDFGoalReasoner ( )
virtualdefault

◆ RDFGoalReasoner() [2/2]

knowrob::RDFGoalReasoner::RDFGoalReasoner ( )
inline

Definition at line 18 of file RDFGoalReasoner.h.

18 : GoalDrivenReasoner() {}

◆ ~RDFGoalReasoner() [2/2]

virtual knowrob::RDFGoalReasoner::~RDFGoalReasoner ( )
virtualdefault

Member Function Documentation

◆ evaluate() [1/4]

bool RDFGoalReasoner::evaluate ( GoalPtr  query)
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.

Parameters
querythe query to evaluate.
Returns
true on success, false otherwise.

Implements knowrob::GoalDrivenReasoner.

Definition at line 11 of file RDFGoalReasoner.cpp.

11  {
12  std::vector<TriplePatternPtr> rdfLiterals;
13  for (auto &lit : query->formula()->literals()) {
14  auto rdfLit = std::dynamic_pointer_cast<TriplePattern>(lit);
15  if (rdfLit) {
16  rdfLiterals.push_back(rdfLit);
17  } else {
18  rdfLiterals.push_back(std::make_shared<TriplePattern>(lit->predicate(), lit->isNegated()));
19  }
20  }
21  auto rdfGoal = std::make_shared<RDFGoal>(rdfLiterals, *query);
22  return evaluate(rdfGoal);
23 }
virtual bool evaluate(RDFGoalPtr query)=0

◆ evaluate() [2/4]

bool knowrob::RDFGoalReasoner::evaluate ( GoalPtr  query)
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.

Parameters
querythe query to evaluate.
Returns
true on success, false otherwise.

Implements knowrob::GoalDrivenReasoner.

◆ evaluate() [3/4]

virtual bool knowrob::RDFGoalReasoner::evaluate ( RDFGoalPtr  query)
pure virtual

Evaluate an RDF goal.

Parameters
querythe goal to evaluate.
Returns
true if the goal is satisfied, false otherwise.

◆ evaluate() [4/4]

virtual bool knowrob::RDFGoalReasoner::evaluate ( RDFGoalPtr  query)
pure virtual

Evaluate an RDF goal.

Parameters
querythe goal to evaluate.
Returns
true if the goal is satisfied, false otherwise.

The documentation for this class was generated from the following files: