knowrob  2.1.0
A Knowledge Base System for Cognition-enabled Robots
Goal.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_H_
7 #define KNOWROB_GOAL_H_
8 
9 #include <ostream>
10 #include <utility>
11 #include <knowrob/semweb/TriplePattern.h>
12 #include <knowrob/queries/TokenBuffer.h>
13 #include <knowrob/queries/Answer.h>
14 #include "knowrob/formulas/SimpleConjunction.h"
15 
16 namespace knowrob {
20  class Goal : public Query {
21  public:
27 
33 
39 
40  ~Goal() override;
41 
45  auto &formula() const { return formula_; }
46 
51  void push(const AnswerPtr &answer);
52 
57  void push(const BindingsPtr &bindings);
58 
63 
67  auto &answerBuffer() const { return answerBuffer_; }
68 
72  auto &outputChannel() const { return outputChannel_; }
73 
74  protected:
75  std::shared_ptr<const QueryContext> ctx_;
76  std::shared_ptr<TokenBuffer> answerBuffer_;
77  std::shared_ptr<TokenStream::Channel> outputChannel_;
78  std::shared_ptr<SimpleConjunction> formula_;
79 
80  // Override Query
81  void write(std::ostream &os) const override { os << *formula_; }
82  };
83 
84  using GoalPtr = std::shared_ptr<Goal>;
85 }
86 
87 #endif //KNOWROB_GOAL_H_
std::shared_ptr< const QueryContext > ctx_
Definition: Goal.h:75
Goal(const FirstOrderLiteralPtr &literal, QueryContextPtr ctx=DefaultQueryContext())
void push(const AnswerPtr &answer)
Goal(SimpleConjunctionPtr formula, QueryContextPtr ctx=DefaultQueryContext())
std::shared_ptr< TokenStream::Channel > outputChannel_
Definition: Goal.h:77
void push(const BindingsPtr &bindings)
~Goal() override
Goal(SimpleConjunctionPtr formula, const Goal &goal)
auto & answerBuffer() const
Definition: Goal.h:67
auto & formula() const
Definition: Goal.h:45
auto & outputChannel() const
Definition: Goal.h:72
void finish()
Definition: Goal.h:62
void write(std::ostream &os) const override
Definition: Goal.h:81
std::shared_ptr< TokenBuffer > answerBuffer_
Definition: Goal.h:76
std::shared_ptr< SimpleConjunction > formula_
Definition: Goal.h:78
auto & ctx() const
Definition: Query.h:41
std::shared_ptr< SimpleConjunction > SimpleConjunctionPtr
std::shared_ptr< const Bindings > BindingsPtr
Definition: Bindings.h:151
QueryContextPtr DefaultQueryContext()
Definition: Query.cpp:11
std::shared_ptr< const QueryContext > QueryContextPtr
Definition: QueryContext.h:41
std::shared_ptr< const Answer > AnswerPtr
Definition: Answer.h:129
std::shared_ptr< FirstOrderLiteral > FirstOrderLiteralPtr
std::shared_ptr< Goal > GoalPtr
Definition: Goal.h:84