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

#include <GraphQuery.h>

Inheritance diagram for knowrob::GraphQuery:
Collaboration diagram for knowrob::GraphQuery:

Public Member Functions

 GraphQuery (const std::shared_ptr< GraphTerm > &query, const QueryContextPtr &ctx=DefaultQueryContext())
 
 GraphQuery (const std::vector< TriplePatternPtr > &query, const QueryContextPtr &ctx=DefaultQueryContext())
 
 GraphQuery (const TriplePatternPtr &query)
 
 GraphQuery (const TriplePatternPtr &query, const QueryContextPtr &ctx)
 
auto term () const
 
FormulaPtr toFormula () const
 
 GraphQuery (const std::shared_ptr< GraphTerm > &query, const QueryContextPtr &ctx=DefaultQueryContext())
 
 GraphQuery (const std::vector< TriplePatternPtr > &query, const QueryContextPtr &ctx=DefaultQueryContext())
 
 GraphQuery (const TriplePatternPtr &query)
 
 GraphQuery (const TriplePatternPtr &query, const QueryContextPtr &ctx)
 
auto term () const
 
FormulaPtr toFormula () const
 
- Public Member Functions inherited from knowrob::Query
 Query (QueryContextPtr ctx=DefaultQueryContext())
 
virtual ~Query ()=default
 
auto & ctx () const
 
void setContext (QueryContextPtr ctx)
 
 Query (QueryContextPtr ctx=DefaultQueryContext())
 
virtual ~Query ()=default
 
auto & ctx () const
 
void setContext (QueryContextPtr ctx)
 
- Public Member Functions inherited from knowrob::Printable
virtual ~Printable ()=default
 
virtual std::string format () const
 
virtual ~Printable ()=default
 
virtual std::string format () const
 

Protected Member Functions

void write (std::ostream &os) const override
 
 GraphQuery (const QueryContextPtr &ctx=DefaultQueryContext())
 
void write (std::ostream &os) const override
 
 GraphQuery (const QueryContextPtr &ctx=DefaultQueryContext())
 

Protected Attributes

std::shared_ptr< GraphTermterm_
 
- Protected Attributes inherited from knowrob::Query
QueryContextPtr ctx_
 

Detailed Description

A Query that is constructed from a sequence of literals which are considered to be in a conjunction. The literals are part of a dependency group, meaning that they are connected through free variables.

Definition at line 18 of file GraphQuery.h.

Constructor & Destructor Documentation

◆ GraphQuery() [1/10]

GraphQuery::GraphQuery ( const std::shared_ptr< GraphTerm > &  query,
const QueryContextPtr ctx = DefaultQueryContext() 
)
explicit
Parameters
queryan ordered sequence of graph terms.
ctxthe query context.

Definition at line 24 of file GraphQuery.cpp.

25  : Query(ctx),
26  term_(queryTerm) {
27 }
std::shared_ptr< GraphTerm > term_
Definition: GraphQuery.h:57
auto & ctx() const
Definition: Query.h:41
Query(QueryContextPtr ctx=DefaultQueryContext())
Definition: Query.h:34

◆ GraphQuery() [2/10]

GraphQuery::GraphQuery ( const std::vector< TriplePatternPtr > &  query,
const QueryContextPtr ctx = DefaultQueryContext() 
)
explicit
Parameters
queryan ordered sequence of triple patterns.
ctxthe query context.

Definition at line 39 of file GraphQuery.cpp.

40  : Query(ctx),
41  term_(std::make_shared<GraphSequence>()) {
42  auto sequence = std::static_pointer_cast<GraphSequence>(term_);
43  for (auto &p: query) {
44  sequence->addPattern(p);
45  }
46 }

◆ GraphQuery() [3/10]

GraphQuery::GraphQuery ( const TriplePatternPtr query)
explicit
Parameters
querya single triple pattern.

Definition at line 29 of file GraphQuery.cpp.

30  : Query(createQueryContext(query)),
31  term_(std::make_shared<GraphPattern>(query)) {
32 }

◆ GraphQuery() [4/10]

GraphQuery::GraphQuery ( const TriplePatternPtr query,
const QueryContextPtr ctx 
)
explicit
Parameters
querya single triple pattern.
ctxthe query context.

Definition at line 34 of file GraphQuery.cpp.

35  : Query(ctx),
36  term_(std::make_shared<GraphPattern>(query)) {
37 }

◆ GraphQuery() [5/10]

knowrob::GraphQuery::GraphQuery ( const QueryContextPtr ctx = DefaultQueryContext())
inlineexplicitprotected

Definition at line 61 of file GraphQuery.h.

61 : Query(ctx) {}

◆ GraphQuery() [6/10]

knowrob::GraphQuery::GraphQuery ( const std::shared_ptr< GraphTerm > &  query,
const QueryContextPtr ctx = DefaultQueryContext() 
)
explicit
Parameters
queryan ordered sequence of graph terms.
ctxthe query context.

◆ GraphQuery() [7/10]

knowrob::GraphQuery::GraphQuery ( const std::vector< TriplePatternPtr > &  query,
const QueryContextPtr ctx = DefaultQueryContext() 
)
explicit
Parameters
queryan ordered sequence of triple patterns.
ctxthe query context.

◆ GraphQuery() [8/10]

knowrob::GraphQuery::GraphQuery ( const TriplePatternPtr query)
explicit
Parameters
querya single triple pattern.

◆ GraphQuery() [9/10]

knowrob::GraphQuery::GraphQuery ( const TriplePatternPtr query,
const QueryContextPtr ctx 
)
explicit
Parameters
querya single triple pattern.
ctxthe query context.

◆ GraphQuery() [10/10]

knowrob::GraphQuery::GraphQuery ( const QueryContextPtr ctx = DefaultQueryContext())
inlineexplicitprotected

Definition at line 61 of file GraphQuery.h.

61 : Query(ctx) {}

Member Function Documentation

◆ term() [1/2]

auto knowrob::GraphQuery::term ( ) const
inline
Returns
the GraphTerm's of the query, which are considered to be in a conjunction.

Definition at line 48 of file GraphQuery.h.

48 { return term_; }

◆ term() [2/2]

auto knowrob::GraphQuery::term ( ) const
inline
Returns
the GraphTerm's of the query, which are considered to be in a conjunction.

Definition at line 48 of file GraphQuery.h.

48 { return term_; }

◆ toFormula() [1/2]

FormulaPtr GraphQuery::toFormula ( ) const

Generate a formula from the graph query.

Returns
a formula that represents the query.

Definition at line 86 of file GraphQuery.cpp.

86  {
87  return toFormula_recursive(term_.get());
88 }

◆ toFormula() [2/2]

FormulaPtr knowrob::GraphQuery::toFormula ( ) const

Generate a formula from the graph query.

Returns
a formula that represents the query.

◆ write() [1/2]

void GraphQuery::write ( std::ostream &  os) const
overrideprotectedvirtual

Print this object to a stream.

Parameters
osthe stream to print to.

Implements knowrob::Printable.

Definition at line 90 of file GraphQuery.cpp.

90  {
91  os << *term_;
92 }

◆ write() [2/2]

void knowrob::GraphQuery::write ( std::ostream &  os) const
overrideprotectedvirtual

Print this object to a stream.

Parameters
osthe stream to print to.

Implements knowrob::Printable.

Member Data Documentation

◆ term_

std::shared_ptr< GraphTerm > knowrob::GraphQuery::term_
protected

Definition at line 57 of file GraphQuery.h.


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