blob: 396a49c470613c26cadcdcba91c4f8b2eb8f0dc5 [file] [log] [blame]
Patrick Venture863b9242018-03-08 08:29:23 -08001#pragma once
2
Patrick Venture863b9242018-03-08 08:29:23 -08003#include "interfaces.hpp"
4#include "sensor.hpp"
5
Patrick Ventureda4a5dd2018-08-31 09:42:48 -07006#include <memory>
7#include <sdbusplus/bus.hpp>
8#include <string>
Patrick Venture863b9242018-03-08 08:29:23 -08009
10/*
11 * A Sensor that can use any reader or writer you provide.
12 */
13class PluggableSensor : public Sensor
14{
Patrick Ventureda4a5dd2018-08-31 09:42:48 -070015 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 Venture863b9242018-03-08 08:29:23 -080023
Patrick Ventureda4a5dd2018-08-31 09:42:48 -070024 ReadReturn read(void) override;
25 void write(double value) override;
James Feist36b7d8e2018-10-05 15:39:01 -070026 bool getFailed(void) override;
Patrick Venture863b9242018-03-08 08:29:23 -080027
Patrick Ventureda4a5dd2018-08-31 09:42:48 -070028 private:
29 std::unique_ptr<ReadInterface> _reader;
30 std::unique_ptr<WriteInterface> _writer;
Patrick Venture863b9242018-03-08 08:29:23 -080031};