| 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> | 
| Krzysztof Grobelny | dcc4e19 | 2021-03-08 09:09:34 +0000 | [diff] [blame] | 9 | #include <vector> | 
| Krzysztof Grobelny | 7f06f61 | 2020-09-24 13:42:10 +0200 | [diff] [blame] | 10 |  | 
 | 11 | namespace interfaces | 
 | 12 | { | 
 | 13 |  | 
| Krzysztof Grobelny | b564594 | 2020-09-29 11:52:45 +0200 | [diff] [blame] | 14 | class SensorListener; | 
 | 15 |  | 
| Krzysztof Grobelny | 7f06f61 | 2020-09-24 13:42:10 +0200 | [diff] [blame] | 16 | class Sensor | 
 | 17 | { | 
 | 18 |   public: | 
 | 19 |     struct Id | 
 | 20 |     { | 
 | 21 |         Id(std::string_view type, std::string_view service, | 
 | 22 |            std::string_view path) : | 
 | 23 |             type(type), | 
 | 24 |             service(service), path(path) | 
 | 25 |         {} | 
 | 26 |  | 
 | 27 |         std::string type; | 
 | 28 |         std::string service; | 
 | 29 |         std::string path; | 
 | 30 |  | 
 | 31 |         bool operator<(const Id& other) const | 
 | 32 |         { | 
 | 33 |             return std::tie(type, service, path) < | 
 | 34 |                    std::tie(other.type, other.service, other.path); | 
 | 35 |         } | 
| Krzysztof Grobelny | b564594 | 2020-09-29 11:52:45 +0200 | [diff] [blame] | 36 |  | 
 | 37 |         inline std::string str() const | 
 | 38 |         { | 
 | 39 |             return type + ":" + service + ":" + path; | 
 | 40 |         } | 
| Krzysztof Grobelny | 7f06f61 | 2020-09-24 13:42:10 +0200 | [diff] [blame] | 41 |     }; | 
 | 42 |  | 
 | 43 |     virtual ~Sensor() = default; | 
 | 44 |  | 
 | 45 |     virtual Id id() const = 0; | 
| Krzysztof Grobelny | b564594 | 2020-09-29 11:52:45 +0200 | [diff] [blame] | 46 |     virtual void registerForUpdates(const std::weak_ptr<SensorListener>&) = 0; | 
| Lukasz Kazmierczak | 7e098e9 | 2021-09-16 15:59:56 +0200 | [diff] [blame] | 47 |     virtual void | 
 | 48 |         unregisterFromUpdates(const std::weak_ptr<SensorListener>&) = 0; | 
| Krzysztof Grobelny | 7f06f61 | 2020-09-24 13:42:10 +0200 | [diff] [blame] | 49 | }; | 
 | 50 |  | 
 | 51 | } // namespace interfaces | 
| Krzysztof Grobelny | dcc4e19 | 2021-03-08 09:09:34 +0000 | [diff] [blame] | 52 |  | 
 | 53 | using Sensors = std::vector<std::shared_ptr<interfaces::Sensor>>; |