knowrob  2.1.0
A Knowledge Base System for Cognition-enabled Robots
TimeInterval.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_TIME_INTERVAL_H_
7 #define KNOWROB_TIME_INTERVAL_H_
8 
9 #include <memory>
10 #include <ostream>
11 #include <optional>
12 #include "TimePoint.h"
13 #include "Printable.h"
14 
15 namespace knowrob {
19  class TimeInterval : public Printable {
20  public:
25  TimeInterval(const std::optional<TimePoint> &since, const std::optional<TimePoint> &until);
26 
31  bool operator==(const TimeInterval &other) const;
32 
36  static const TimeInterval &anytime();
37 
42 
48  static TimeInterval during(const TimePoint &begin, const TimePoint &end);
49 
54  std::shared_ptr<TimeInterval> intersectWith(const TimeInterval &other) const;
55 
59  const auto &since() const { return since_; }
60 
64  const auto &until() const { return until_; }
65 
66  // Printable interface
67  void write(std::ostream &os) const override;
68 
69  protected:
70  std::optional<TimePoint> since_;
71  std::optional<TimePoint> until_;
72  };
73 }
74 
75 #endif //KNOWROB_TIME_INTERVAL_H_
std::optional< TimePoint > until_
Definition: TimeInterval.h:71
TimeInterval(const std::optional< TimePoint > &since, const std::optional< TimePoint > &until)
void write(std::ostream &os) const override
static const TimeInterval & anytime()
static TimeInterval during(const TimePoint &begin, const TimePoint &end)
std::optional< TimePoint > since_
Definition: TimeInterval.h:70
static TimeInterval currently()
const auto & since() const
Definition: TimeInterval.h:59
const auto & until() const
Definition: TimeInterval.h:64
bool operator==(const TimeInterval &other) const
std::shared_ptr< TimeInterval > intersectWith(const TimeInterval &other) const
std::chrono::time_point< std::chrono::system_clock, std::chrono::seconds > TimePoint
Definition: TimePoint.h:16