knowrob  2.1.0
A Knowledge Base System for Cognition-enabled Robots
SimpleConjunction.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/formulas/SimpleConjunction.h>
7 #include "knowrob/formulas/Negation.h"
8 #include "knowrob/integration/python/utils.h"
9 
10 using namespace knowrob;
11 
12 std::vector<FormulaPtr> literalsToFormulae(const std::vector<FirstOrderLiteralPtr> &literals) {
13  std::vector<FormulaPtr> formulae;
14  for (const auto &literal: literals) {
15  if (literal->isNegated()) {
16  formulae.push_back(std::make_shared<Negation>(literal->predicate()));
17  } else {
18  formulae.push_back(literal->predicate());
19  }
20  }
21  return formulae;
22 }
23 
24 SimpleConjunction::SimpleConjunction(const std::vector<FirstOrderLiteralPtr> &literals)
25  : Conjunction(literalsToFormulae(literals)), literals_(literals) {
26 }
27 
29  : SimpleConjunction(std::vector<FirstOrderLiteralPtr>{literal}) {
30 }
31 
32 namespace knowrob::py {
33  template<>
35  using namespace boost::python;
36  class_<SimpleConjunction, std::shared_ptr<SimpleConjunction>, bases<Conjunction>>
37  ("SimpleConjunction", init<const std::vector<FirstOrderLiteralPtr> &>()).
38  def("literals", &SimpleConjunction::literals, return_value_policy<copy_const_reference>());
39  }
40 }
41 
std::vector< FormulaPtr > literalsToFormulae(const std::vector< FirstOrderLiteralPtr > &literals)
SimpleConjunction(const std::vector< FirstOrderLiteralPtr > &literals)
void createType< SimpleConjunction >()
std::shared_ptr< FirstOrderLiteral > FirstOrderLiteralPtr