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 { 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 } 38 39 inline std::string str() const 40 { 41 return type + ":" + service + ":" + path; 42 } 43 }; 44 45 virtual ~Sensor() = default; 46 47 virtual Id id() const = 0; 48 virtual std::string metadata() const = 0; 49 virtual std::string getName() const = 0; 50 virtual void registerForUpdates(const std::weak_ptr<SensorListener>&) = 0; 51 virtual void 52 unregisterFromUpdates(const std::weak_ptr<SensorListener>&) = 0; 53 54 virtual LabeledSensorInfo getLabeledSensorInfo() const = 0; 55 }; 56 57 } // namespace interfaces 58 59 using Sensors = std::vector<std::shared_ptr<interfaces::Sensor>>; 60