1 #pragma once 2 3 #include <chrono> 4 #include <memory> 5 #include <ostream> 6 #include <string> 7 #include <string_view> 8 #include <tuple> 9 #include <vector> 10 11 namespace interfaces 12 { 13 14 class SensorListener; 15 16 class Sensor 17 { 18 public: 19 struct Id 20 { 21 Id(std::string_view type, std::string_view service, 22 std::string_view path) : 23 type(type), 24 service(service), path(path) 25 {} 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 } 36 37 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 void registerForUpdates(const std::weak_ptr<SensorListener>&) = 0; 48 virtual void 49 unregisterFromUpdates(const std::weak_ptr<SensorListener>&) = 0; 50 }; 51 52 } // namespace interfaces 53 54 using Sensors = std::vector<std::shared_ptr<interfaces::Sensor>>; 55