knowrob  2.1.0
A Knowledge Base System for Cognition-enabled Robots
Function.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_FUNCTION_H
7 #define KNOWROB_FUNCTION_H
8 
9 #include "vector"
10 #include "Term.h"
11 #include "Atom.h"
12 
13 namespace knowrob {
17  class Function : public Term {
18  public:
24  Function(AtomPtr functor, const std::vector<TermPtr> &arguments);
25 
31  Function(std::string_view functor, const std::vector<TermPtr> &arguments);
32 
37  bool isSameFunction(const Function &other) const;
38 
42  auto &functor() const { return functor_; }
43 
47  auto &arguments() const { return arguments_; }
48 
52  auto arity() const { return arguments_.size(); }
53 
57  size_t hashOfFunction() const;
58 
59  // Override Term
60  const std::set<std::string_view> &variables() const override { return variables_; }
61 
62  // Override Printable
63  void write(std::ostream &os) const override;
64 
65  protected:
66  const std::shared_ptr<Atom> functor_;
67  const std::vector<TermPtr> arguments_;
68  const std::set<std::string_view> variables_;
69 
70  std::set<std::string_view> getVariables1() const;
71  };
72 
73  using FunctionPtr = std::shared_ptr<Function>;
74 
75 } // knowrob
76 
77 #endif //KNOWROB_FUNCTION_H
const std::set< std::string_view > variables_
Definition: Function.h:68
auto arity() const
Definition: Function.h:52
size_t hashOfFunction() const
Function(std::string_view functor, const std::vector< TermPtr > &arguments)
const std::shared_ptr< Atom > functor_
Definition: Function.h:66
std::set< std::string_view > getVariables1() const
const std::vector< TermPtr > arguments_
Definition: Function.h:67
const std::set< std::string_view > & variables() const override
Definition: Function.h:60
bool isSameFunction(const Function &other) const
auto & arguments() const
Definition: Function.h:47
auto & functor() const
Definition: Function.h:42
Function(AtomPtr functor, const std::vector< TermPtr > &arguments)
void write(std::ostream &os) const override
std::shared_ptr< Function > FunctionPtr
Definition: Function.h:73
std::shared_ptr< Atom > AtomPtr
Definition: Atom.h:69