knowrob  2.1.0
A Knowledge Base System for Cognition-enabled Robots
RDFGoal.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/reasoner/RDFGoal.h>
7 
8 #include <utility>
9 #include "knowrob/integration/python/utils.h"
10 
11 using namespace knowrob;
12 
13 static SimpleConjunctionPtr makeSimpleConjunction(const std::vector<TriplePatternPtr> &literals) {
14  std::vector<FirstOrderLiteralPtr> firstOrderLiterals;
15  firstOrderLiterals.reserve(literals.size());
16  for (const auto &literal : literals) {
17  firstOrderLiterals.push_back(literal);
18  }
19  return std::make_shared<SimpleConjunction>(firstOrderLiterals);
20 }
21 
22 RDFGoal::RDFGoal(const std::vector<TriplePatternPtr> &literals, const Goal &goal)
23  : Goal(makeSimpleConjunction(literals), goal), rdfLiterals_(literals) {
24 }
25 
26 RDFGoal::RDFGoal(const std::vector<TriplePatternPtr> &literals, const QueryContextPtr &ctx)
27  : Goal(makeSimpleConjunction(literals), ctx), rdfLiterals_(literals) {
28 }
29 
31  : Goal(literal, ctx), rdfLiterals_({literal}) {
32 }
33 
34 namespace knowrob::py {
35  template<>
37  using namespace boost::python;
38 
39  class_<RDFGoal, std::shared_ptr<RDFGoal>, bases<Goal>>
40  ("RDFGoal", init<const std::vector<TriplePatternPtr> &, QueryContextPtr>())
41  .def(init<const TriplePatternPtr &, QueryContextPtr>())
42  .def("rdfLiterals", &RDFGoal::rdfLiterals, return_value_policy<copy_const_reference>());
43  }
44 }
45 
auto & rdfLiterals() const
Definition: RDFGoal.h:36
RDFGoal(const std::vector< TriplePatternPtr > &literals, const QueryContextPtr &ctx=DefaultQueryContext())
Definition: RDFGoal.cpp:26
void createType< RDFGoal >()
Definition: RDFGoal.cpp:36
std::shared_ptr< TriplePattern > TriplePatternPtr
std::shared_ptr< SimpleConjunction > SimpleConjunctionPtr
std::shared_ptr< const QueryContext > QueryContextPtr
Definition: QueryContext.h:41