1 #pragma once 2 3 #include "types/sensor_types.hpp" 4 5 #include <chrono> 6 #include <memory> 7 #include <ostream> 8 #include <string> 9 #include <string_view> 10 #include <tuple> 11 #include <vector> 12 13 namespace interfaces 14 { 15 16 class SensorListener; 17 18 class Sensor 19 { 20 public: 21 struct Id 22 { Idinterfaces::Sensor::Id23 Id(std::string_view type, std::string_view service, 24 std::string_view path) : type(type), service(service), path(path) 25 {} 26 27 std::string type; 28 std::string service; 29 std::string path; 30 operator <interfaces::Sensor::Id31 bool operator<(const Id& other) const 32 { 33 return std::tie(type, service, path) < 34 std::tie(other.type, other.service, other.path); 35 } 36 strinterfaces::Sensor::Id37 inline std::string str() const 38 { 39 return type + ":" + service + ":" + path; 40 } 41 }; 42 43 virtual ~Sensor() = default; 44 45 virtual Id id() const = 0; 46 virtual std::string metadata() const = 0; 47 virtual std::string getName() const = 0; 48 virtual void registerForUpdates(const std::weak_ptr<SensorListener>&) = 0; 49 virtual void 50 unregisterFromUpdates(const std::weak_ptr<SensorListener>&) = 0; 51 52 virtual LabeledSensorInfo getLabeledSensorInfo() const = 0; 53 }; 54 55 } // namespace interfaces 56 57 using Sensors = std::vector<std::shared_ptr<interfaces::Sensor>>; 58