blob: 6a6bcf70009e325bb318595fd6de58183701213b [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 Grobelnyb8cc78d2021-11-29 15:54:53 +010046 virtual std::string metadata() const = 0;
Krzysztof Grobelnyb5645942020-09-29 11:52:45 +020047 virtual void registerForUpdates(const std::weak_ptr<SensorListener>&) = 0;
Lukasz Kazmierczak7e098e92021-09-16 15:59:56 +020048 virtual void
49 unregisterFromUpdates(const std::weak_ptr<SensorListener>&) = 0;
Krzysztof Grobelny7f06f612020-09-24 13:42:10 +020050};
51
52} // namespace interfaces
Krzysztof Grobelnydcc4e192021-03-08 09:09:34 +000053
54using Sensors = std::vector<std::shared_ptr<interfaces::Sensor>>;