BeeeOn Gateway  v2020.3.1-2-g6f737dc
Platform to interconnect the IoT world
RefreshTime.h
1 #pragma once
2 
3 #include <iosfwd>
4 #include <string>
5 
6 #include <Poco/Timespan.h>
7 
8 namespace BeeeOn {
9 
24 class RefreshTime {
25 public:
26  static const RefreshTime NONE;
27  static const RefreshTime DISABLED;
28 
29  RefreshTime();
30 
31 private:
32  RefreshTime(const Poco::Timespan &time);
33 
34 public:
35  bool isDisabled() const;
36  bool isNone() const;
37 
38  Poco::Timespan time() const;
39  int seconds() const;
40 
41  operator Poco::Timespan() const
42  {
43  return time();
44  }
45 
46  bool operator ==(const RefreshTime &other) const;
47  bool operator !=(const RefreshTime &other) const;
48  bool operator <(const RefreshTime &other) const;
49  bool operator <=(const RefreshTime &other) const;
50  bool operator >(const RefreshTime &other) const;
51  bool operator >=(const RefreshTime &other) const;
52 
53  std::string toString() const;
54  static RefreshTime fromSeconds(const int seconds);
55  static RefreshTime fromMinutes(const int minutes);
56  static RefreshTime parse(const std::string &input);
57 
58 private:
59  Poco::Timespan m_time;
60 };
61 
62 inline std::ostream &operator <<(std::ostream &s, const RefreshTime &time)
63 {
64  return s << time.toString();
65 }
66 
67 }
RefreshTime represents time of refreshing values from sensors. E.g. sensors are polled periodically o...
Definition: RefreshTime.h:24