knowrob  2.1.0
A Knowledge Base System for Cognition-enabled Robots
ConjunctiveQuery.cpp
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 #include "knowrob/queries/ConjunctiveQuery.h"
7 #include "knowrob/semweb/GraphPattern.h"
8 #include "knowrob/formulas/Conjunction.h"
9 #include "knowrob/integration/python/utils.h"
10 
11 using namespace knowrob;
12 
14  : Query(ctx),
15  formula_(std::make_shared<SimpleConjunction>(query)) {
16 }
17 
18 ConjunctiveQuery::ConjunctiveQuery(const std::vector<FirstOrderLiteralPtr> &query, const QueryContextPtr &ctx)
19  : Query(ctx),
20  formula_(std::make_shared<SimpleConjunction>(query)) {
21 }
22 
23 void ConjunctiveQuery::write(std::ostream &os) const {
24  os << *formula_;
25 }
26 
27 namespace knowrob::py {
28  template<>
30  using namespace boost::python;
31 
33 
34  class_<ConjunctiveQuery, std::shared_ptr<ConjunctiveQuery>, boost::noncopyable>
35  ("GraphQuery", init<const FirstOrderLiteralPtr &, const QueryContextPtr &>())
36  .def(init<const std::vector<FirstOrderLiteralPtr> &, const QueryContextPtr &>())
37  .def("formula", &ConjunctiveQuery::formula, return_value_policy<copy_const_reference>())
38  .def("literals", &ConjunctiveQuery::literals, return_value_policy<copy_const_reference>());
39  }
40 }
ConjunctiveQuery(const std::vector< FirstOrderLiteralPtr > &query, const QueryContextPtr &ctx=DefaultQueryContext())
void write(std::ostream &os) const override
SimpleConjunctionPtr formula_
void createType< GraphTerm >()
Definition: GraphTerm.cpp:90
void createType< ConjunctiveQuery >()
std::shared_ptr< const QueryContext > QueryContextPtr
Definition: QueryContext.h:41
std::shared_ptr< FirstOrderLiteral > FirstOrderLiteralPtr