Patrick Venture | 863b924 | 2018-03-08 08:29:23 -0800 | [diff] [blame] | 1 | #pragma once |
2 | |||||
Patrick Venture | 863b924 | 2018-03-08 08:29:23 -0800 | [diff] [blame] | 3 | #include "interfaces.hpp" |
James Feist | 0c8223b | 2019-05-08 15:33:33 -0700 | [diff] [blame] | 4 | #include "util.hpp" |
Patrick Venture | 863b924 | 2018-03-08 08:29:23 -0800 | [diff] [blame] | 5 | |
Patrick Venture | da4a5dd | 2018-08-31 09:42:48 -0700 | [diff] [blame] | 6 | #include <string> |
Patrick Venture | 863b924 | 2018-03-08 08:29:23 -0800 | [diff] [blame] | 7 | |
8 | /* | ||||
9 | * A WriteInterface that is expecting a path that's sysfs, but really could be | ||||
10 | * any filesystem path. | ||||
11 | */ | ||||
12 | class SysFsWritePercent : public WriteInterface | ||||
13 | { | ||||
Patrick Venture | da4a5dd | 2018-08-31 09:42:48 -0700 | [diff] [blame] | 14 | public: |
Patrick Venture | a1c5d37 | 2019-02-11 10:03:35 -0800 | [diff] [blame] | 15 | SysFsWritePercent(const std::string& writePath, int64_t min, int64_t max) : |
16 | WriteInterface(min, max), _writePath(FixupPath(writePath)) | ||||
Patrick Venture | a83a3ec | 2020-08-04 09:52:05 -0700 | [diff] [blame^] | 17 | {} |
Patrick Venture | 863b924 | 2018-03-08 08:29:23 -0800 | [diff] [blame] | 18 | |
Patrick Venture | da4a5dd | 2018-08-31 09:42:48 -0700 | [diff] [blame] | 19 | void write(double value) override; |
Patrick Venture | 863b924 | 2018-03-08 08:29:23 -0800 | [diff] [blame] | 20 | |
Patrick Venture | da4a5dd | 2018-08-31 09:42:48 -0700 | [diff] [blame] | 21 | private: |
Patrick Venture | a1c5d37 | 2019-02-11 10:03:35 -0800 | [diff] [blame] | 22 | std::string _writePath; |
Patrick Venture | 863b924 | 2018-03-08 08:29:23 -0800 | [diff] [blame] | 23 | }; |
24 | |||||
25 | class SysFsWrite : public WriteInterface | ||||
26 | { | ||||
Patrick Venture | da4a5dd | 2018-08-31 09:42:48 -0700 | [diff] [blame] | 27 | public: |
Patrick Venture | a1c5d37 | 2019-02-11 10:03:35 -0800 | [diff] [blame] | 28 | SysFsWrite(const std::string& writePath, int64_t min, int64_t max) : |
29 | WriteInterface(min, max), _writePath(FixupPath(writePath)) | ||||
Patrick Venture | a83a3ec | 2020-08-04 09:52:05 -0700 | [diff] [blame^] | 30 | {} |
Patrick Venture | 863b924 | 2018-03-08 08:29:23 -0800 | [diff] [blame] | 31 | |
Patrick Venture | da4a5dd | 2018-08-31 09:42:48 -0700 | [diff] [blame] | 32 | void write(double value) override; |
Patrick Venture | 863b924 | 2018-03-08 08:29:23 -0800 | [diff] [blame] | 33 | |
Patrick Venture | da4a5dd | 2018-08-31 09:42:48 -0700 | [diff] [blame] | 34 | private: |
Patrick Venture | a1c5d37 | 2019-02-11 10:03:35 -0800 | [diff] [blame] | 35 | std::string _writePath; |
Patrick Venture | 863b924 | 2018-03-08 08:29:23 -0800 | [diff] [blame] | 36 | }; |