blob: 276d936c46d03bd78f7a1ba94693b3e18b0848a8 [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"
James Feist0c8223b2019-05-08 15:33:33 -07004#include "util.hpp"
Patrick Venture863b9242018-03-08 08:29:23 -08005
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 Venturea83a3ec2020-08-04 09:52:05 -070017 {}
Patrick Venture863b9242018-03-08 08:29:23 -080018
Patrick Ventureda4a5dd2018-08-31 09:42:48 -070019 void write(double value) override;
Patrick Venture863b9242018-03-08 08:29:23 -080020
Patrick Ventureda4a5dd2018-08-31 09:42:48 -070021 private:
Patrick Venturea1c5d372019-02-11 10:03:35 -080022 std::string _writePath;
Patrick Venture863b9242018-03-08 08:29:23 -080023};
24
25class SysFsWrite : public WriteInterface
26{
Patrick Ventureda4a5dd2018-08-31 09:42:48 -070027 public:
Patrick Venturea1c5d372019-02-11 10:03:35 -080028 SysFsWrite(const std::string& writePath, int64_t min, int64_t max) :
29 WriteInterface(min, max), _writePath(FixupPath(writePath))
Patrick Venturea83a3ec2020-08-04 09:52:05 -070030 {}
Patrick Venture863b9242018-03-08 08:29:23 -080031
Patrick Ventureda4a5dd2018-08-31 09:42:48 -070032 void write(double value) override;
Patrick Venture863b9242018-03-08 08:29:23 -080033
Patrick Ventureda4a5dd2018-08-31 09:42:48 -070034 private:
Patrick Venturea1c5d372019-02-11 10:03:35 -080035 std::string _writePath;
Patrick Venture863b9242018-03-08 08:29:23 -080036};