blob: 78a762e792387e73900062a39365679862c41498 [file] [log] [blame]
Krzysztof Grobelny7f06f612020-09-24 13:42:10 +02001#pragma once
2
Szymon Dompke94f71c52021-12-10 07:16:33 +01003#include "types/sensor_types.hpp"
4
Krzysztof Grobelnyb5645942020-09-29 11:52:45 +02005#include <chrono>
6#include <memory>
Krzysztof Grobelny7f06f612020-09-24 13:42:10 +02007#include <ostream>
8#include <string>
9#include <string_view>
10#include <tuple>
Krzysztof Grobelnydcc4e192021-03-08 09:09:34 +000011#include <vector>
Krzysztof Grobelny7f06f612020-09-24 13:42:10 +020012
13namespace interfaces
14{
15
Krzysztof Grobelnyb5645942020-09-29 11:52:45 +020016class SensorListener;
17
Krzysztof Grobelny7f06f612020-09-24 13:42:10 +020018class Sensor
19{
20 public:
21 struct Id
22 {
23 Id(std::string_view type, std::string_view service,
Patrick Williamsf535cad2024-08-16 15:21:20 -040024 std::string_view path) : type(type), service(service), path(path)
Krzysztof Grobelny7f06f612020-09-24 13:42:10 +020025 {}
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;
Szymon Dompke94f71c52021-12-10 07:16:33 +010047 virtual std::string getName() const = 0;
Krzysztof Grobelnyb5645942020-09-29 11:52:45 +020048 virtual void registerForUpdates(const std::weak_ptr<SensorListener>&) = 0;
Lukasz Kazmierczak7e098e92021-09-16 15:59:56 +020049 virtual void
50 unregisterFromUpdates(const std::weak_ptr<SensorListener>&) = 0;
Szymon Dompke94f71c52021-12-10 07:16:33 +010051
52 virtual LabeledSensorInfo getLabeledSensorInfo() const = 0;
Krzysztof Grobelny7f06f612020-09-24 13:42:10 +020053};
54
55} // namespace interfaces
Krzysztof Grobelnydcc4e192021-03-08 09:09:34 +000056
57using Sensors = std::vector<std::shared_ptr<interfaces::Sensor>>;