6 #ifndef KNOWROB_PROLOG_TERM_H
7 #define KNOWROB_PROLOG_TERM_H
9 #include <SWI-Prolog.h>
10 #include "knowrob/terms/Term.h"
11 #include "knowrob/formulas/Formula.h"
12 #include "knowrob/formulas/CompoundFormula.h"
13 #include "knowrob/semweb/Triple.h"
14 #include "knowrob/semweb/TriplePattern.h"
15 #include "knowrob/semweb/GraphQuery.h"
16 #include "knowrob/semweb/GraphBuiltin.h"
17 #include "knowrob/terms/Function.h"
18 #include "knowrob/terms/ListTerm.h"
22 #define KNOWROB_USE_PROLOG_RDF_DB
29 class PrologTerm :
public Printable {
91 explicit PrologTerm(
const std::shared_ptr<GraphTerm> &kbTerm);
123 PrologTerm(
const std::vector<PrologTerm> &args, std::string_view functor);
131 template<
typename ... Args>
132 explicit PrologTerm(std::string_view functor, Args &&... args)
190 bool putTerm(
const std::shared_ptr<GraphTerm> &kbTerm);
263 void write(std::ostream &os)
const override;
266 std::map<Variable, term_t, std::less<>>
vars_;
267 std::optional<std::string_view>
module_;
282 bool putCompoundTerm(term_t plTerm, std::string_view functor,
const std::vector<PrologTerm> &args);
284 bool putTerm(
const std::shared_ptr<GraphTerm> &
term, term_t plTerm);
292 bool putBuiltin(
const std::shared_ptr<GraphBuiltin> &builtin, term_t plTerm);
296 template<
typename ... Args>
297 std::vector<PrologTerm>
readArgs(Args &&... args) {
300 std::vector<PrologTerm> argTerms;
301 ([&args, &argTerms] { argTerms.push_back(
PrologTerm(args)); }(), ...);
308 class PrologList :
public PrologTerm {
310 explicit PrologList(
const std::vector<PrologTerm> &elements);
PrologList(const std::vector< PrologTerm > &elements)
static const predicate_t & PREDICATE_comma()
PrologTerm operator&(const PrologTerm &other) const
bool putTerm(const TermPtr &kbTerm, term_t plTerm)
static const functor_t & FUNCTOR_semicolon()
static const atom_t & ATOM_semicolon()
static const predicate_t & PREDICATE_semicolon()
static const functor_t & FUNCTOR_comma()
bool putTriplePattern(const TriplePattern &pattern, const char *functor, term_t plTerm)
bool putTriple(std::string_view functor, const Triple &triple)
bool putTerm(const std::shared_ptr< GraphTerm > &term, term_t plTerm)
void setModule(std::string_view module)
bool putList(ListTerm *list, term_t pl_term)
PrologTerm operator|(const PrologTerm &other) const
FormulaPtr toKnowRobFormula() const
bool putRDFAtomic(const std::shared_ptr< Atomic > &atomic, term_t pl_term) const
bool putCompoundTerm(term_t plTerm, std::string_view functor, const std::vector< PrologTerm > &args)
static bool putNativeAtomic(const std::shared_ptr< Atomic > &atomic, term_t pl_term)
PrologTerm(const FormulaPtr &kbFormula)
PrologTerm(const std::shared_ptr< GraphTerm > &kbTerm)
std::map< Variable, term_t, std::less<> > vars_
PrologTerm(const TermPtr &kbTerm)
bool putFormula(const FormulaPtr &phi, term_t plTerm)
PrologTerm(const Triple &triple, std::string_view functor)
static const atom_t & ATOM_false()
bool putCompound(CompoundFormula *phi, term_t pl_term, const functor_t &pl_functor)
static bool display(std::ostream &os, term_t t, const std::string &indent="")
static FormulaPtr toKnowRobFormula(const TermPtr &t)
qid_t openQuery(int flags) const
PrologTerm(const GraphQueryPtr &query)
static TermPtr toKnowRobTerm(const term_t &t)
PrologTerm(const TriplePattern &literal, const char *triple_functor)
std::optional< std::string_view > module_
bool putBuiltin(const std::shared_ptr< GraphBuiltin > &builtin, term_t plTerm)
std::vector< PrologTerm > readArgs(Args &&... args)
void write(std::ostream &os) const override
TermPtr toKnowRobTerm() const
static const atom_t & ATOM_true()
static bool nextSolution(qid_t qid)
static const atom_t & ATOM_fail()
PrologTerm operator~() const
bool putFormula(const FormulaPtr &phi)
bool putTerm(const std::shared_ptr< GraphTerm > &kbTerm)
PrologTerm(std::string_view functor, Args &&... args)
PrologTerm(const PrologTerm &other)=default
static std::string getVarName(term_t plTerm)
static const atom_t & ATOM_comma()
term_t operator()() const
void unifyVars(const PrologTerm &other)
bool putTerm(const TermPtr &kbTerm)
PrologTerm(const std::vector< PrologTerm > &args, std::string_view functor)
bool putFunction(Function *fn, term_t pl_term)
GraphTermRule & pattern()
std::shared_ptr< Term > TermPtr
std::shared_ptr< Formula > FormulaPtr
std::shared_ptr< GraphQuery > GraphQueryPtr