knowrob  2.1.0
A Knowledge Base System for Cognition-enabled Robots
pair.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_PY_CONVERTER_PAIR_H
7 #define KNOWROB_PY_CONVERTER_PAIR_H
8 
9 #include <boost/python.hpp>
10 #include <boost/python/suite/indexing/vector_indexing_suite.hpp>
11 
12 
13 namespace knowrob::py {
14  // Converter from C++ pair to Python tuple
15  struct PairToTupleConverter {
16  static PyObject *
17  convert(const std::pair<std::basic_string_view<char, std::char_traits<char> > const, std::pair<std::shared_ptr<knowrob::Variable>, std::shared_ptr<knowrob::Term> > > &pair) {
18  return boost::python::incref(
19  boost::python::make_tuple(pair.first, pair.second.first, pair.second.second).ptr());
20  }
21  };
22 
23  // Register the converter in the module initialization function
25  boost::python::to_python_converter<std::pair<std::basic_string_view<char, std::char_traits<char> > const, std::pair<std::shared_ptr<knowrob::Variable>, std::shared_ptr<knowrob::Term> > >, PairToTupleConverter>();
26  }
27 }
28 
29 #endif //KNOWROB_PY_CONVERTER_PAIR_H
void register_pair_converter()
Definition: pair.h:24
static PyObject * convert(const std::pair< std::basic_string_view< char, std::char_traits< char > > const, std::pair< std::shared_ptr< knowrob::Variable >, std::shared_ptr< knowrob::Term > > > &pair)
Definition: pair.h:17