Patrick Venture | 863b924 | 2018-03-08 08:29:23 -0800 | [diff] [blame] | 1 | #pragma once |
| 2 | |
Patrick Venture | 863b924 | 2018-03-08 08:29:23 -0800 | [diff] [blame] | 3 | #include "interfaces.hpp" |
| 4 | #include "sensor.hpp" |
| 5 | |
Patrick Venture | da4a5dd | 2018-08-31 09:42:48 -0700 | [diff] [blame] | 6 | #include <memory> |
| 7 | #include <sdbusplus/bus.hpp> |
| 8 | #include <string> |
Patrick Venture | 863b924 | 2018-03-08 08:29:23 -0800 | [diff] [blame] | 9 | |
| 10 | /* |
| 11 | * A Sensor that can use any reader or writer you provide. |
| 12 | */ |
| 13 | class PluggableSensor : public Sensor |
| 14 | { |
Patrick Venture | da4a5dd | 2018-08-31 09:42:48 -0700 | [diff] [blame] | 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 | } |
Patrick Venture | 863b924 | 2018-03-08 08:29:23 -0800 | [diff] [blame] | 23 | |
Patrick Venture | da4a5dd | 2018-08-31 09:42:48 -0700 | [diff] [blame] | 24 | ReadReturn read(void) override; |
| 25 | void write(double value) override; |
James Feist | 36b7d8e | 2018-10-05 15:39:01 -0700 | [diff] [blame] | 26 | bool getFailed(void) override; |
Patrick Venture | 863b924 | 2018-03-08 08:29:23 -0800 | [diff] [blame] | 27 | |
Patrick Venture | da4a5dd | 2018-08-31 09:42:48 -0700 | [diff] [blame] | 28 | private: |
| 29 | std::unique_ptr<ReadInterface> _reader; |
| 30 | std::unique_ptr<WriteInterface> _writer; |
Patrick Venture | 863b924 | 2018-03-08 08:29:23 -0800 | [diff] [blame] | 31 | }; |