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 <sdbusplus/bus.hpp> |
Patrick Venture | a83a3ec | 2020-08-04 09:52:05 -0700 | [diff] [blame^] | 7 | |
| 8 | #include <memory> |
Patrick Venture | da4a5dd | 2018-08-31 09:42:48 -0700 | [diff] [blame] | 9 | #include <string> |
Patrick Venture | 863b924 | 2018-03-08 08:29:23 -0800 | [diff] [blame] | 10 | |
| 11 | /* |
| 12 | * A Sensor that can use any reader or writer you provide. |
| 13 | */ |
| 14 | class PluggableSensor : public Sensor |
| 15 | { |
Patrick Venture | da4a5dd | 2018-08-31 09:42:48 -0700 | [diff] [blame] | 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)) |
Patrick Venture | a83a3ec | 2020-08-04 09:52:05 -0700 | [diff] [blame^] | 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 | }; |