knowrob  2.1.0
A Knowledge Base System for Cognition-enabled Robots
OptionList.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_OPTION_LIST_H_
7 #define KNOWROB_OPTION_LIST_H_
8 
9 #include <map>
10 #include <optional>
11 #include <string>
12 #include "Term.h"
13 
14 namespace knowrob {
18  class OptionList {
19  public:
26  explicit OptionList(const TermPtr &t);
27 
31  const std::map<std::string, TermPtr> &options() const { return options_; }
32 
37  bool contains(const std::string &key) const;
38 
44  const TermPtr &get(const std::string &key, const TermPtr &defaultValue) const;
45 
52  std::string_view getString(const std::string &key, const std::string &defaultValue) const;
53 
60  long getLong(const std::string &key, long defaultValue) const;
61 
67  std::optional<double> getDouble(const std::string &key) const;
68 
69  protected:
70  std::map<std::string, TermPtr> options_;
71 
72  void readOption(const TermPtr &option);
73  };
74 }
75 
76 #endif //KNOWROB_OPTION_LIST_H_
std::optional< double > getDouble(const std::string &key) const
bool contains(const std::string &key) const
OptionList(const TermPtr &t)
const std::map< std::string, TermPtr > & options() const
Definition: OptionList.h:31
const TermPtr & get(const std::string &key, const TermPtr &defaultValue) const
long getLong(const std::string &key, long defaultValue) const
std::string_view getString(const std::string &key, const std::string &defaultValue) const
void readOption(const TermPtr &option)
std::map< std::string, TermPtr > options_
Definition: OptionList.h:70
TermRule & option()
Definition: terms.cpp:110
TermRule & string()
Definition: terms.cpp:63
std::shared_ptr< Term > TermPtr
Definition: Term.h:117