blob: 07c7897ddcf1c52df5d0410b65609f503db48bba [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>
9
10namespace interfaces
11{
12
Krzysztof Grobelnyb5645942020-09-29 11:52:45 +020013class SensorListener;
14
Krzysztof Grobelny7f06f612020-09-24 13:42:10 +020015class 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 Grobelnyb5645942020-09-29 11:52:45 +020035
36 inline std::string str() const
37 {
38 return type + ":" + service + ":" + path;
39 }
Krzysztof Grobelny7f06f612020-09-24 13:42:10 +020040 };
41
42 virtual ~Sensor() = default;
43
44 virtual Id id() const = 0;
Krzysztof Grobelnyb5645942020-09-29 11:52:45 +020045 virtual void registerForUpdates(const std::weak_ptr<SensorListener>&) = 0;
Krzysztof Grobelny7f06f612020-09-24 13:42:10 +020046};
47
48} // namespace interfaces