Krzysztof Grobelny | 7f06f61 | 2020-09-24 13:42:10 +0200 | [diff] [blame] | 1 | #pragma once |
| 2 | |
Krzysztof Grobelny | b564594 | 2020-09-29 11:52:45 +0200 | [diff] [blame^] | 3 | #include <chrono> |
| 4 | #include <memory> |
Krzysztof Grobelny | 7f06f61 | 2020-09-24 13:42:10 +0200 | [diff] [blame] | 5 | #include <ostream> |
| 6 | #include <string> |
| 7 | #include <string_view> |
| 8 | #include <tuple> |
| 9 | |
| 10 | namespace interfaces |
| 11 | { |
| 12 | |
Krzysztof Grobelny | b564594 | 2020-09-29 11:52:45 +0200 | [diff] [blame^] | 13 | class SensorListener; |
| 14 | |
Krzysztof Grobelny | 7f06f61 | 2020-09-24 13:42:10 +0200 | [diff] [blame] | 15 | class Sensor |
| 16 | { |
| 17 | public: |
| 18 | struct Id |
| 19 | { |
| 20 | Id(std::string_view type, std::string_view service, |
| 21 | std::string_view path) : |
| 22 | type(type), |
| 23 | service(service), path(path) |
| 24 | {} |
| 25 | |
| 26 | std::string type; |
| 27 | std::string service; |
| 28 | std::string path; |
| 29 | |
| 30 | bool operator<(const Id& other) const |
| 31 | { |
| 32 | return std::tie(type, service, path) < |
| 33 | std::tie(other.type, other.service, other.path); |
| 34 | } |
Krzysztof Grobelny | b564594 | 2020-09-29 11:52:45 +0200 | [diff] [blame^] | 35 | |
| 36 | inline std::string str() const |
| 37 | { |
| 38 | return type + ":" + service + ":" + path; |
| 39 | } |
Krzysztof Grobelny | 7f06f61 | 2020-09-24 13:42:10 +0200 | [diff] [blame] | 40 | }; |
| 41 | |
| 42 | virtual ~Sensor() = default; |
| 43 | |
| 44 | virtual Id id() const = 0; |
Krzysztof Grobelny | b564594 | 2020-09-29 11:52:45 +0200 | [diff] [blame^] | 45 | virtual void registerForUpdates(const std::weak_ptr<SensorListener>&) = 0; |
Krzysztof Grobelny | 7f06f61 | 2020-09-24 13:42:10 +0200 | [diff] [blame] | 46 | }; |
| 47 | |
| 48 | } // namespace interfaces |