xref: /openbmc/phosphor-pid-control/sysfs/sysfswrite.hpp (revision f8b6e55147148c3cfb42327ff267197a460b411c)
1 #pragma once
2 
3 #include "interfaces.hpp"
4 #include "util.hpp"
5 
6 #include <cstdint>
7 #include <string>
8 
9 namespace pid_control
10 {
11 
12 /*
13  * A WriteInterface that is expecting a path that's sysfs, but really could be
14  * any filesystem path.
15  */
16 class SysFsWritePercent : public WriteInterface
17 {
18   public:
SysFsWritePercent(const std::string & writePath,int64_t min,int64_t max)19     SysFsWritePercent(const std::string& writePath, int64_t min, int64_t max) :
20         WriteInterface(min, max), _writePath(FixupPath(writePath))
21     {}
22 
23     void write(double value) override;
24 
25   private:
26     std::string _writePath;
27 };
28 
29 class SysFsWrite : public WriteInterface
30 {
31   public:
SysFsWrite(const std::string & writePath,int64_t min,int64_t max)32     SysFsWrite(const std::string& writePath, int64_t min, int64_t max) :
33         WriteInterface(min, max), _writePath(FixupPath(writePath))
34     {}
35 
36     void write(double value) override;
37 
38   private:
39     std::string _writePath;
40 };
41 
42 } // namespace pid_control
43