knowrob  2.1.0
A Knowledge Base System for Cognition-enabled Robots
QueryPipeline.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_QUERY_PIPELINE_H
7 #define KNOWROB_QUERY_PIPELINE_H
8 
9 #include "memory"
10 #include "vector"
11 #include "TokenStream.h"
12 #include "knowrob/formulas/DependencyGraph.h"
13 #include "knowrob/semweb/GraphPathQuery.h"
14 #include "ConjunctiveQuery.h"
15 #include "knowrob/reasoner/Computable.h"
16 
17 namespace knowrob {
18  class KnowledgeBase;
19 
25  class QueryPipeline {
26  public:
33  QueryPipeline(const std::shared_ptr<KnowledgeBase> &kb, const FormulaPtr &phi, const QueryContextPtr &ctx);
34 
40  QueryPipeline(const std::shared_ptr<KnowledgeBase> &kb, const ConjunctiveQueryPtr &conjunctiveQuery);
41 
43 
48  void operator>>(const std::shared_ptr<TokenStream> &stage);
49 
53  void stopBuffering();
54 
55  protected:
56  std::vector<std::shared_ptr<TokenStream>> initialStages_;
57  std::shared_ptr<TokenBroadcaster> finalStage_;
58  std::shared_ptr<TokenBuffer> bufferStage_;
59 
60  void addInitialStage(const std::shared_ptr<TokenStream> &stage);
61 
62  static std::vector<ComputablePtr> createComputationSequence(
63  const std::shared_ptr<KnowledgeBase> &kb,
64  const std::list<DependencyNodePtr> &dependencyGroup);
65 
67  const std::shared_ptr<KnowledgeBase> &kb,
68  std::vector<ComputablePtr> &computableLiterals,
69  const std::shared_ptr<TokenBroadcaster> &pipelineInput,
70  const std::shared_ptr<TokenBroadcaster> &pipelineOutput,
71  const QueryContextPtr &ctx);
72  };
73 
80  public:
81  explicit AnswerBuffer_WithReference(const std::shared_ptr<QueryPipeline> &pipeline)
82  : TokenBuffer(), pipeline_(pipeline) {}
83 
84  protected:
85  std::shared_ptr<QueryPipeline> pipeline_;
86  };
87 }
88 
89 
90 #endif //KNOWROB_QUERY_PIPELINE_H
AnswerBuffer_WithReference(const std::shared_ptr< QueryPipeline > &pipeline)
Definition: QueryPipeline.h:81
std::shared_ptr< QueryPipeline > pipeline_
Definition: QueryPipeline.h:85
void addInitialStage(const std::shared_ptr< TokenStream > &stage)
std::vector< std::shared_ptr< TokenStream > > initialStages_
Definition: QueryPipeline.h:56
QueryPipeline(const std::shared_ptr< KnowledgeBase > &kb, const FormulaPtr &phi, const QueryContextPtr &ctx)
static std::vector< ComputablePtr > createComputationSequence(const std::shared_ptr< KnowledgeBase > &kb, const std::list< DependencyNodePtr > &dependencyGroup)
std::shared_ptr< TokenBroadcaster > finalStage_
Definition: QueryPipeline.h:57
std::shared_ptr< TokenBuffer > bufferStage_
Definition: QueryPipeline.h:58
static void createComputationPipeline(const std::shared_ptr< KnowledgeBase > &kb, std::vector< ComputablePtr > &computableLiterals, const std::shared_ptr< TokenBroadcaster > &pipelineInput, const std::shared_ptr< TokenBroadcaster > &pipelineOutput, const QueryContextPtr &ctx)
QueryPipeline(const std::shared_ptr< KnowledgeBase > &kb, const ConjunctiveQueryPtr &conjunctiveQuery)
void operator>>(const std::shared_ptr< TokenStream > &stage)
std::shared_ptr< Formula > FormulaPtr
Definition: Formula.h:99
std::shared_ptr< ConjunctiveQuery > ConjunctiveQueryPtr
std::shared_ptr< const QueryContext > QueryContextPtr
Definition: QueryContext.h:41