knowrob  2.1.0
A Knowledge Base System for Cognition-enabled Robots
knowrob::SWRLReasoner Class Reference

#include <SWRLReasoner.h>

Inheritance diagram for knowrob::SWRLReasoner:
Collaboration diagram for knowrob::SWRLReasoner:

Public Member Functions

 SWRLReasoner ()
 
bool loadSWRLFile (const DataSourcePtr &dataFile)
 
void unload () override
 
 SWRLReasoner ()
 
bool loadSWRLFile (const DataSourcePtr &dataFile)
 
void unload () override
 
- Public Member Functions inherited from knowrob::PrologReasoner
 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< TermPtrrunTests (const std::string &target)
 
bool initializeReasoner (const PropertyTree &cfg) override
 
bool evaluate (GoalPtr query) 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< TermPtrrunTests (const std::string &target)
 
bool initializeReasoner (const PropertyTree &cfg) override
 
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)
 
 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)
 
- 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 Attributes

static const std::string SWRL_FORMAT = "pl-swrl"
 

Protected Member Functions

bool initializeDefaultPackages () override
 
bool initializeDefaultPackages () override
 
- Protected Member Functions inherited from knowrob::PrologReasoner
virtual bool initializeGlobalPackages ()
 
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 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)
 

Additional Inherited Members

- Static Public Member Functions inherited from knowrob::PrologReasoner
static std::shared_ptr< NamedReasonergetDefinedReasoner (const term_t &t_reasonerManager, const term_t &t_reasonerModule)
 
static std::shared_ptr< NamedReasonergetDefinedReasoner (const term_t &t_reasonerManager, const term_t &t_reasonerModule)
 
- Static Protected Member Functions inherited from knowrob::PrologReasoner
static bool putQueryFrame (PrologTerm &frameTerm, const GraphSelector &frame)
 
static std::shared_ptr< GraphSelectorcreateAnswerFrame (const PrologTerm &plTerm)
 
static bool putQueryFrame (PrologTerm &frameTerm, const GraphSelector &frame)
 
static std::shared_ptr< GraphSelectorcreateAnswerFrame (const PrologTerm &plTerm)
 
- Protected Attributes inherited from knowrob::PrologReasoner
std::shared_ptr< PrologBackendknowledgeGraph_
 
- 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_
 
- Static Protected Attributes inherited from knowrob::PrologReasoner
static bool isKnowRobInitialized_ = false
 

Detailed Description

Definition at line 14 of file SWRLReasoner.h.

Constructor & Destructor Documentation

◆ SWRLReasoner() [1/2]

SWRLReasoner::SWRLReasoner ( )

Definition at line 17 of file SWRLReasoner.cpp.

18  : PrologReasoner() {
20  (const DataSourcePtr &dataFile) { return loadSWRLFile(dataFile); });
21 }
void addDataHandler(const std::string &format, const DataSourceLoader &fn)
static const std::string SWRL_FORMAT
Definition: SWRLReasoner.h:16
bool loadSWRLFile(const DataSourcePtr &dataFile)
std::shared_ptr< DataSource > DataSourcePtr
Definition: DataSource.h:107

◆ SWRLReasoner() [2/2]

knowrob::SWRLReasoner::SWRLReasoner ( )

Member Function Documentation

◆ initializeDefaultPackages() [1/2]

bool SWRLReasoner::initializeDefaultPackages ( )
overrideprotectedvirtual

Reimplemented from knowrob::PrologReasoner.

Definition at line 37 of file SWRLReasoner.cpp.

37  {
38  KB_DEBUG("Initializing SWRL module.");
39  return consult(std::filesystem::path("reasoner") / "swrl" / "__init__.pl", nullptr, false);
40 }
#define KB_DEBUG
Definition: Logger.h:25
bool consult(const std::filesystem::path &uri, const char *module={}, bool doTransformQuery=true)

◆ initializeDefaultPackages() [2/2]

bool knowrob::SWRLReasoner::initializeDefaultPackages ( )
overrideprotectedvirtual

Reimplemented from knowrob::PrologReasoner.

◆ loadSWRLFile() [1/2]

bool SWRLReasoner::loadSWRLFile ( const DataSourcePtr dataFile)

Definition at line 30 of file SWRLReasoner.cpp.

30  {
31  static auto consult_f = "swrl_file_load";
32  auto path = PrologEngine::getResourcePath(dataFile->uri());
33  KB_INFO("Loading SWRL file: {}", dataFile->uri());
34  return PROLOG_ENGINE_EVAL(getReasonerQuery(PrologTerm(consult_f, path.native())));
35 }
#define KB_INFO
Definition: Logger.h:26
#define PROLOG_ENGINE_EVAL(term)
Definition: PrologEngine.h:128
static std::filesystem::path getResourcePath(const std::filesystem::path &filename)
PrologTerm getReasonerQuery(const PrologTerm &goal)

◆ loadSWRLFile() [2/2]

bool knowrob::SWRLReasoner::loadSWRLFile ( const DataSourcePtr dataFile)

◆ unload() [1/2]

void SWRLReasoner::unload ( )
overridevirtual

Unload the reasoner, meaning that all static resources associated to this reasoner are released.

Reimplemented from knowrob::PrologReasoner.

Definition at line 23 of file SWRLReasoner.cpp.

23  {
24  static auto unload_f = "swrl_reasoner_unload";
26  // also unload the PrologReasoner
28 }

◆ unload() [2/2]

void knowrob::SWRLReasoner::unload ( )
overridevirtual

Unload the reasoner, meaning that all static resources associated to this reasoner are released.

Reimplemented from knowrob::PrologReasoner.

Member Data Documentation

◆ SWRL_FORMAT

const std::string SWRLReasoner::SWRL_FORMAT = "pl-swrl"
static

Definition at line 16 of file SWRLReasoner.h.


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