Krzysztof Grobelny | 7f06f61 | 2020-09-24 13:42:10 +0200 | [diff] [blame] | 1 | #pragma once |
| 2 | |
Szymon Dompke | 94f71c5 | 2021-12-10 07:16:33 +0100 | [diff] [blame] | 3 | #include "types/sensor_types.hpp" |
| 4 | |
Krzysztof Grobelny | b564594 | 2020-09-29 11:52:45 +0200 | [diff] [blame] | 5 | #include <chrono> |
| 6 | #include <memory> |
Krzysztof Grobelny | 7f06f61 | 2020-09-24 13:42:10 +0200 | [diff] [blame] | 7 | #include <ostream> |
| 8 | #include <string> |
| 9 | #include <string_view> |
| 10 | #include <tuple> |
Krzysztof Grobelny | dcc4e19 | 2021-03-08 09:09:34 +0000 | [diff] [blame] | 11 | #include <vector> |
Krzysztof Grobelny | 7f06f61 | 2020-09-24 13:42:10 +0200 | [diff] [blame] | 12 | |
| 13 | namespace interfaces |
| 14 | { |
| 15 | |
Krzysztof Grobelny | b564594 | 2020-09-29 11:52:45 +0200 | [diff] [blame] | 16 | class SensorListener; |
| 17 | |
Krzysztof Grobelny | 7f06f61 | 2020-09-24 13:42:10 +0200 | [diff] [blame] | 18 | class Sensor |
| 19 | { |
| 20 | public: |
| 21 | struct Id |
| 22 | { |
| 23 | Id(std::string_view type, std::string_view service, |
| 24 | std::string_view path) : |
| 25 | type(type), |
| 26 | service(service), path(path) |
| 27 | {} |
| 28 | |
| 29 | std::string type; |
| 30 | std::string service; |
| 31 | std::string path; |
| 32 | |
| 33 | bool operator<(const Id& other) const |
| 34 | { |
| 35 | return std::tie(type, service, path) < |
| 36 | std::tie(other.type, other.service, other.path); |
| 37 | } |
Krzysztof Grobelny | b564594 | 2020-09-29 11:52:45 +0200 | [diff] [blame] | 38 | |
| 39 | inline std::string str() const |
| 40 | { |
| 41 | return type + ":" + service + ":" + path; |
| 42 | } |
Krzysztof Grobelny | 7f06f61 | 2020-09-24 13:42:10 +0200 | [diff] [blame] | 43 | }; |
| 44 | |
| 45 | virtual ~Sensor() = default; |
| 46 | |
| 47 | virtual Id id() const = 0; |
Krzysztof Grobelny | b8cc78d | 2021-11-29 15:54:53 +0100 | [diff] [blame] | 48 | virtual std::string metadata() const = 0; |
Szymon Dompke | 94f71c5 | 2021-12-10 07:16:33 +0100 | [diff] [blame] | 49 | virtual std::string getName() const = 0; |
Krzysztof Grobelny | b564594 | 2020-09-29 11:52:45 +0200 | [diff] [blame] | 50 | virtual void registerForUpdates(const std::weak_ptr<SensorListener>&) = 0; |
Lukasz Kazmierczak | 7e098e9 | 2021-09-16 15:59:56 +0200 | [diff] [blame] | 51 | virtual void |
| 52 | unregisterFromUpdates(const std::weak_ptr<SensorListener>&) = 0; |
Szymon Dompke | 94f71c5 | 2021-12-10 07:16:33 +0100 | [diff] [blame] | 53 | |
| 54 | virtual LabeledSensorInfo getLabeledSensorInfo() const = 0; |
Krzysztof Grobelny | 7f06f61 | 2020-09-24 13:42:10 +0200 | [diff] [blame] | 55 | }; |
| 56 | |
| 57 | } // namespace interfaces |
Krzysztof Grobelny | dcc4e19 | 2021-03-08 09:09:34 +0000 | [diff] [blame] | 58 | |
| 59 | using Sensors = std::vector<std::shared_ptr<interfaces::Sensor>>; |