Brandon Wyman | 3f1242f | 2020-01-28 13:11:25 -0600 | [diff] [blame] | 1 | #pragma once |
| 2 | |
| 3 | #include "types.hpp" |
| 4 | |
| 5 | #include <sdbusplus/bus/match.hpp> |
| 6 | |
| 7 | namespace phosphor::power::psu |
| 8 | { |
| 9 | |
| 10 | /** |
| 11 | * @class UtilBase |
| 12 | * A base class to allow for mocking certain utility functions. |
| 13 | */ |
| 14 | class UtilBase |
| 15 | { |
| 16 | public: |
| 17 | virtual ~UtilBase() = default; |
| 18 | |
| 19 | virtual bool getPresence(sdbusplus::bus::bus& bus, |
| 20 | const std::string& invpath) const = 0; |
B. J. Wyman | 681b2a3 | 2021-04-20 22:31:22 +0000 | [diff] [blame] | 21 | |
| 22 | virtual void setPresence(sdbusplus::bus::bus& bus, |
| 23 | const std::string& invpath, bool present, |
| 24 | const std::string& name) const = 0; |
Brandon Wyman | 3f1242f | 2020-01-28 13:11:25 -0600 | [diff] [blame] | 25 | }; |
| 26 | |
| 27 | const UtilBase& getUtils(); |
| 28 | |
| 29 | inline bool getPresence(sdbusplus::bus::bus& bus, const std::string& invpath) |
| 30 | { |
| 31 | return getUtils().getPresence(bus, invpath); |
| 32 | } |
| 33 | |
B. J. Wyman | 681b2a3 | 2021-04-20 22:31:22 +0000 | [diff] [blame] | 34 | inline void setPresence(sdbusplus::bus::bus& bus, const std::string& invpath, |
| 35 | bool present, const std::string& name) |
| 36 | { |
| 37 | return getUtils().setPresence(bus, invpath, present, name); |
| 38 | } |
| 39 | |
| 40 | class GPIOInterface |
| 41 | { |
| 42 | public: |
| 43 | virtual ~GPIOInterface() = default; |
| 44 | |
| 45 | virtual int read() = 0; |
B. J. Wyman | d8b8cb1 | 2021-07-15 22:03:34 +0000 | [diff] [blame] | 46 | virtual std::string getName() const = 0; |
B. J. Wyman | 681b2a3 | 2021-04-20 22:31:22 +0000 | [diff] [blame] | 47 | }; |
| 48 | |
Brandon Wyman | 3f1242f | 2020-01-28 13:11:25 -0600 | [diff] [blame] | 49 | } // namespace phosphor::power::psu |