1 #pragma once
2 
3 #include "interfaces.hpp"
4 #include "sensor.hpp"
5 
6 #include <memory>
7 #include <sdbusplus/bus.hpp>
8 #include <string>
9 
10 /*
11  * A Sensor that can use any reader or writer you provide.
12  */
13 class PluggableSensor : public Sensor
14 {
15   public:
16     PluggableSensor(const std::string& name, int64_t timeout,
17                     std::unique_ptr<ReadInterface> reader,
18                     std::unique_ptr<WriteInterface> writer) :
19         Sensor(name, timeout),
20         _reader(std::move(reader)), _writer(std::move(writer))
21     {
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