blob: 23aea9949b9a65afd639b933f4a6aa7d03d15aef [file] [log] [blame]
#pragma once
#include "interfaces.hpp"
#include "sensor.hpp"
#include <memory>
#include <string>
namespace pid_control
{
/*
* 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;
};
} // namespace pid_control