blob: 9510dff6ba2f3e4e0b0c5483bf9c3f02879d789c [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:
15 SysFsWritePercent(const std::string& writepath, int64_t min, int64_t max) :
16 WriteInterface(min, max), _writepath(FixupPath(writepath))
17 {
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:
23 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:
29 SysFsWrite(const std::string& writepath, int64_t min, int64_t max) :
30 WriteInterface(min, max), _writepath(FixupPath(writepath))
31 {
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:
37 std::string _writepath;
Patrick Venture863b9242018-03-08 08:29:23 -080038};