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