blob: 3e46317eed76791ee4ad61989fa57cce7b3f41c0 [file] [log] [blame]
Krzysztof Grobelny7f06f612020-09-24 13:42:10 +02001#pragma once
2
Krzysztof Grobelnyb5645942020-09-29 11:52:45 +02003#include <chrono>
4#include <memory>
Krzysztof Grobelny7f06f612020-09-24 13:42:10 +02005#include <ostream>
6#include <string>
7#include <string_view>
8#include <tuple>
Krzysztof Grobelnydcc4e192021-03-08 09:09:34 +00009#include <vector>
Krzysztof Grobelny7f06f612020-09-24 13:42:10 +020010
11namespace interfaces
12{
13
Krzysztof Grobelnyb5645942020-09-29 11:52:45 +020014class SensorListener;
15
Krzysztof Grobelny7f06f612020-09-24 13:42:10 +020016class 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 Grobelnyb5645942020-09-29 11:52:45 +020036
37 inline std::string str() const
38 {
39 return type + ":" + service + ":" + path;
40 }
Krzysztof Grobelny7f06f612020-09-24 13:42:10 +020041 };
42
43 virtual ~Sensor() = default;
44
45 virtual Id id() const = 0;
Krzysztof Grobelnyb5645942020-09-29 11:52:45 +020046 virtual void registerForUpdates(const std::weak_ptr<SensorListener>&) = 0;
Krzysztof Grobelny7f06f612020-09-24 13:42:10 +020047};
48
49} // namespace interfaces
Krzysztof Grobelnydcc4e192021-03-08 09:09:34 +000050
51using Sensors = std::vector<std::shared_ptr<interfaces::Sensor>>;