blob: f877d4a00ed78f31ecae8b7f1ee4d1752d959972 [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 "sysfs/util.hpp"
5
Patrick Ventureda4a5dd2018-08-31 09:42:48 -07006#include <string>
Patrick Venture863b9242018-03-08 08:29:23 -08007
8/*
9 * A WriteInterface that is expecting a path that's sysfs, but really could be
10 * any filesystem path.
11 */
12class SysFsWritePercent : public WriteInterface
13{
Patrick Ventureda4a5dd2018-08-31 09:42:48 -070014 public:
Patrick Venturea1c5d372019-02-11 10:03:35 -080015 SysFsWritePercent(const std::string& writePath, int64_t min, int64_t max) :
16 WriteInterface(min, max), _writePath(FixupPath(writePath))
Patrick Ventureda4a5dd2018-08-31 09:42:48 -070017 {
18 }
Patrick Venture863b9242018-03-08 08:29:23 -080019
Patrick Ventureda4a5dd2018-08-31 09:42:48 -070020 void write(double value) override;
Patrick Venture863b9242018-03-08 08:29:23 -080021
Patrick Ventureda4a5dd2018-08-31 09:42:48 -070022 private:
Patrick Venturea1c5d372019-02-11 10:03:35 -080023 std::string _writePath;
Patrick Venture863b9242018-03-08 08:29:23 -080024};
25
26class SysFsWrite : public WriteInterface
27{
Patrick Ventureda4a5dd2018-08-31 09:42:48 -070028 public:
Patrick Venturea1c5d372019-02-11 10:03:35 -080029 SysFsWrite(const std::string& writePath, int64_t min, int64_t max) :
30 WriteInterface(min, max), _writePath(FixupPath(writePath))
Patrick Ventureda4a5dd2018-08-31 09:42:48 -070031 {
32 }
Patrick Venture863b9242018-03-08 08:29:23 -080033
Patrick Ventureda4a5dd2018-08-31 09:42:48 -070034 void write(double value) override;
Patrick Venture863b9242018-03-08 08:29:23 -080035
Patrick Ventureda4a5dd2018-08-31 09:42:48 -070036 private:
Patrick Venturea1c5d372019-02-11 10:03:35 -080037 std::string _writePath;
Patrick Venture863b9242018-03-08 08:29:23 -080038};