1 #pragma once 2 3 #include <chrono> 4 #include <memory> 5 #include <ostream> 6 #include <string> 7 #include <string_view> 8 #include <tuple> 9 10 namespace interfaces 11 { 12 13 class SensorListener; 14 15 class Sensor 16 { 17 public: 18 struct Id 19 { 20 Id(std::string_view type, std::string_view service, 21 std::string_view path) : 22 type(type), 23 service(service), path(path) 24 {} 25 26 std::string type; 27 std::string service; 28 std::string path; 29 30 bool operator<(const Id& other) const 31 { 32 return std::tie(type, service, path) < 33 std::tie(other.type, other.service, other.path); 34 } 35 36 inline std::string str() const 37 { 38 return type + ":" + service + ":" + path; 39 } 40 }; 41 42 virtual ~Sensor() = default; 43 44 virtual Id id() const = 0; 45 virtual void registerForUpdates(const std::weak_ptr<SensorListener>&) = 0; 46 }; 47 48 } // namespace interfaces 49