knowrob  2.1.0
A Knowledge Base System for Cognition-enabled Robots
ModalOperator.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_MODAL_OPERATOR_H
7 #define KNOWROB_MODAL_OPERATOR_H
8 
9 #include <list>
10 #include <map>
11 #include <optional>
12 #include "knowrob/terms/Term.h"
13 #include "knowrob/semweb/Perspective.h"
14 #include "knowrob/TimeInterval.h"
15 
16 namespace knowrob {
20  enum class ModalType {
21  KNOWLEDGE = 1,
22  BELIEF,
23  ALWAYS,
24  SOMETIMES
25  };
26 
31  class ModalOperator {
32  public:
33  static constexpr const char* KEY_PERSPECTIVE = "agent";
34  static constexpr const char* KEY_CONFIDENCE = "confidence";
35  static constexpr const char* KEY_BEGIN = "begin";
36  static constexpr const char* KEY_END = "end";
37 
42 
47  bool operator==(const ModalOperator &other) const;
48 
52  bool isModalNecessity() const;
53 
57  bool isModalPossibility() const;
58 
62  auto modalType() const { return modalType_; }
63 
67  const char *symbol() const;
68 
73  void setParameter(std::string_view key, const TermPtr &value);
74 
79  std::optional<TermPtr> parameter(std::string_view key) const;
80 
84  std::optional<PerspectivePtr> perspective() const;
85 
89  void setPerspective(const std::string_view &agent);
90 
94  std::optional<double> confidence() const;
95 
99  void setConfidence(double confidence);
100 
104  std::optional<double> begin() const;
105 
109  void setBegin(double begin);
110 
114  std::optional<double> end() const;
115 
119  void setEnd(double end);
120 
124  void setTimeInterval(const TimeInterval &timeInterval);
125 
129  void write(std::ostream &os) const;
130 
131  protected:
132  const ModalType modalType_;
133  std::map<std::string, TermPtr> parameters_;
134  };
135 
136  using ModalOperatorPtr = std::shared_ptr<const ModalOperator>;
137 
142  class ModalIteration {
143  public:
144  ModalIteration() = default;
145 
150  bool operator==(const ModalIteration &other) const;
151 
155  void operator+=(const ModalOperatorPtr &modalOperator);
156 
157  ModalIteration operator+(const ModalOperatorPtr &modalOperator) const;
158 
162  auto numOperators() const { return modalitySequence_.size(); }
163 
167  auto begin() const { return modalitySequence_.begin(); }
168 
172  auto end() const { return modalitySequence_.end(); }
173 
178 
179  protected:
180  std::list<ModalOperatorPtr> modalitySequence_;
181  };
182 
183 } // knowrob
184 
185 #endif //KNOWROB_MODAL_OPERATOR_H
static const ModalIteration & emptyIteration()
bool operator==(const ModalIteration &other) const
std::list< ModalOperatorPtr > modalitySequence_
void operator+=(const ModalOperatorPtr &modalOperator)
ModalIteration operator+(const ModalOperatorPtr &modalOperator) const
std::optional< double > end() const
ModalOperator(ModalType modalType)
void setTimeInterval(const TimeInterval &timeInterval)
auto modalType() const
Definition: ModalOperator.h:62
std::map< std::string, TermPtr > parameters_
void write(std::ostream &os) const
std::optional< double > end() const
bool isModalNecessity() const
void setPerspective(const std::string_view &agent)
const ModalType modalType_
void setBegin(double begin)
const char * symbol() const
std::optional< TermPtr > parameter(std::string_view key) const
std::optional< PerspectivePtr > perspective() const
void setEnd(double end)
std::optional< double > begin() const
void setParameter(std::string_view key, const TermPtr &value)
bool isModalPossibility() const
static constexpr const char * KEY_END
Definition: ModalOperator.h:36
static constexpr const char * KEY_CONFIDENCE
Definition: ModalOperator.h:34
void setConfidence(double confidence)
std::optional< double > confidence() const
std::optional< double > begin() const
bool operator==(const ModalOperator &other) const
static constexpr const char * KEY_BEGIN
Definition: ModalOperator.h:35
static constexpr const char * KEY_PERSPECTIVE
Definition: ModalOperator.h:33
std::optional< double > confidence() const
std::shared_ptr< Term > TermPtr
Definition: Term.h:117
std::shared_ptr< const ModalOperator > ModalOperatorPtr