blob: 7764b37b3889cf2f9524e94bc31c6d22f81a49a3 [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,
24 std::string_view path) :
25 type(type),
26 service(service), path(path)
27 {}
28
29 std::string type;
30 std::string service;
31 std::string path;
32
33 bool operator<(const Id& other) const
34 {
35 return std::tie(type, service, path) <
36 std::tie(other.type, other.service, other.path);
37 }
Krzysztof Grobelnyb5645942020-09-29 11:52:45 +020038
39 inline std::string str() const
40 {
41 return type + ":" + service + ":" + path;
42 }
Krzysztof Grobelny7f06f612020-09-24 13:42:10 +020043 };
44
45 virtual ~Sensor() = default;
46
47 virtual Id id() const = 0;
Krzysztof Grobelnyb8cc78d2021-11-29 15:54:53 +010048 virtual std::string metadata() const = 0;
Szymon Dompke94f71c52021-12-10 07:16:33 +010049 virtual std::string getName() const = 0;
Krzysztof Grobelnyb5645942020-09-29 11:52:45 +020050 virtual void registerForUpdates(const std::weak_ptr<SensorListener>&) = 0;
Lukasz Kazmierczak7e098e92021-09-16 15:59:56 +020051 virtual void
52 unregisterFromUpdates(const std::weak_ptr<SensorListener>&) = 0;
Szymon Dompke94f71c52021-12-10 07:16:33 +010053
54 virtual LabeledSensorInfo getLabeledSensorInfo() const = 0;
Krzysztof Grobelny7f06f612020-09-24 13:42:10 +020055};
56
57} // namespace interfaces
Krzysztof Grobelnydcc4e192021-03-08 09:09:34 +000058
59using Sensors = std::vector<std::shared_ptr<interfaces::Sensor>>;