summaryrefslogtreecommitdiffstats
path: root/sensors/pluggable.hpp
blob: 396a49c470613c26cadcdcba91c4f8b2eb8f0dc5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#pragma once

#include "interfaces.hpp"
#include "sensor.hpp"

#include <memory>
#include <sdbusplus/bus.hpp>
#include <string>

/*
 * A Sensor that can use any reader or writer you provide.
 */
class PluggableSensor : public Sensor
{
  public:
    PluggableSensor(const std::string& name, int64_t timeout,
                    std::unique_ptr<ReadInterface> reader,
                    std::unique_ptr<WriteInterface> writer) :
        Sensor(name, timeout),
        _reader(std::move(reader)), _writer(std::move(writer))
    {
    }

    ReadReturn read(void) override;
    void write(double value) override;
    bool getFailed(void) override;

  private:
    std::unique_ptr<ReadInterface> _reader;
    std::unique_ptr<WriteInterface> _writer;
};
OpenPOWER on IntegriCloud