blob: 005d9adabea52b2eb19b8f2018f311d1ba9797f4 [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;
Patrick Venture863b9242018-03-08 08:29:23 -080026
Patrick Ventureda4a5dd2018-08-31 09:42:48 -070027 private:
28 std::unique_ptr<ReadInterface> _reader;
29 std::unique_ptr<WriteInterface> _writer;
Patrick Venture863b9242018-03-08 08:29:23 -080030};