knowrob  2.1.0
A Knowledge Base System for Cognition-enabled Robots
GoalDrivenReasoner.h
Go to the documentation of this file.
1 /*
2  * This file is part of KnowRob, please consult
3  * https://github.com/knowrob/knowrob for license details.
4  */
5 
6 #ifndef KNOWROB_GOAL_DRIVEN_REASONER_H
7 #define KNOWROB_GOAL_DRIVEN_REASONER_H
8 
9 #include "Reasoner.h"
10 #include "Goal.h"
11 #include "knowrob/formulas/PredicateIndicator.h"
12 
13 namespace knowrob {
32  };
33 
40  class GoalDrivenReasoner : public Reasoner {
41  public:
43 
48 
53 
61  bool isRelationDefined(const PredicateIndicator &indicator);
62 
70  bool isClassDefined(const std::string_view &iri);
71 
76  void defineRelation(const PredicateIndicator &indicator);
77 
83 
88  void undefineRelation(const PredicateIndicator &indicator);
89 
94  void defineClass(const IRIAtomPtr &iri);
95 
101 
105  const auto &definedRelations() const { return definedRelations_; }
106 
110  const auto &definedClasses() const { return definedClasses_; }
111 
123  virtual bool evaluate(GoalPtr query) = 0;
124 
125  protected:
126  std::set<PredicateIndicator> definedRelations_;
127  std::set<PredicateIndicator> definedClasses_;
128  int features_;
129  };
130 
134  class ReasonerRunner : public ThreadPool::Runner {
135  public:
136  std::shared_ptr<GoalDrivenReasoner> reasoner;
137  std::shared_ptr<Goal> query;
138 
139  ReasonerRunner() = default;
140 
141  // ThreadPool::Runner interface
142  void run() override;
143 
144  private:
145  void run_();
146  };
147 
148  using GoalDrivenReasonerPtr = std::shared_ptr<GoalDrivenReasoner>;
149  using DefiningReasoner = std::pair<GoalDrivenReasonerPtr,AtomPtr>;
150 }
151 
152 #endif //KNOWROB_GOAL_DRIVEN_REASONER_H
void undefineRelation(const PredicateIndicator &indicator)
const auto & definedClasses() const
std::set< PredicateIndicator > definedRelations_
const auto & definedRelations() const
bool hasFeature(GoalDrivenReasonerFeature feature) const
bool isClassDefined(const std::string_view &iri)
bool isRelationDefined(const PredicateIndicator &indicator)
void enableFeature(GoalDrivenReasonerFeature feature)
virtual bool evaluate(GoalPtr query)=0
void undefineClass(const IRIAtomPtr &iri)
void defineRelation(const PredicateIndicator &indicator)
void defineRelation(const IRIAtomPtr &iri)
void defineClass(const IRIAtomPtr &iri)
std::set< PredicateIndicator > definedClasses_
std::shared_ptr< GoalDrivenReasoner > reasoner
void run() override
std::shared_ptr< Goal > query
std::pair< GoalDrivenReasonerPtr, AtomPtr > DefiningReasoner
IRIAtomPtr iri(std::string_view ns, std::string_view name)
Definition: IRIAtom.cpp:62
std::shared_ptr< IRIAtom > IRIAtomPtr
Definition: IRIAtom.h:57
std::shared_ptr< GoalDrivenReasoner > GoalDrivenReasonerPtr
std::shared_ptr< Goal > GoalPtr
Definition: Goal.h:84