1 #pragma once 2 3 #include "interfaces.hpp" 4 #include "sensor.hpp" 5 6 #include <sdbusplus/bus.hpp> 7 8 #include <memory> 9 #include <string> 10 11 /* 12 * A Sensor that can use any reader or writer you provide. 13 */ 14 class PluggableSensor : public Sensor 15 { 16 public: 17 PluggableSensor(const std::string& name, int64_t timeout, 18 std::unique_ptr<ReadInterface> reader, 19 std::unique_ptr<WriteInterface> writer) : 20 Sensor(name, timeout), 21 _reader(std::move(reader)), _writer(std::move(writer)) 22 {} 23 24 ReadReturn read(void) override; 25 void write(double value) override; 26 bool getFailed(void) override; 27 28 private: 29 std::unique_ptr<ReadInterface> _reader; 30 std::unique_ptr<WriteInterface> _writer; 31 }; 32