blob: ade43ef87617d3eb613096bc3dc61cc1c46c3b5e [file] [log] [blame]
Brandon Wyman3f1242f2020-01-28 13:11:25 -06001#pragma once
2
3#include "types.hpp"
4
5#include <sdbusplus/bus/match.hpp>
6
7namespace phosphor::power::psu
8{
9
10/**
11 * @class UtilBase
12 * A base class to allow for mocking certain utility functions.
13 */
14class 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. Wyman681b2a32021-04-20 22:31:22 +000021
22 virtual void setPresence(sdbusplus::bus::bus& bus,
23 const std::string& invpath, bool present,
24 const std::string& name) const = 0;
Brandon Wyman3f1242f2020-01-28 13:11:25 -060025};
26
27const UtilBase& getUtils();
28
29inline bool getPresence(sdbusplus::bus::bus& bus, const std::string& invpath)
30{
31 return getUtils().getPresence(bus, invpath);
32}
33
B. J. Wyman681b2a32021-04-20 22:31:22 +000034inline 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
Adriana Kobylak3ca062a2021-10-20 15:27:23 +000040class GPIOInterfaceBase
B. J. Wyman681b2a32021-04-20 22:31:22 +000041{
42 public:
Adriana Kobylak3ca062a2021-10-20 15:27:23 +000043 virtual ~GPIOInterfaceBase() = default;
B. J. Wyman681b2a32021-04-20 22:31:22 +000044
45 virtual int read() = 0;
B. J. Wymand8b8cb12021-07-15 22:03:34 +000046 virtual std::string getName() const = 0;
B. J. Wyman681b2a32021-04-20 22:31:22 +000047};
48
Brandon Wyman3f1242f2020-01-28 13:11:25 -060049} // namespace phosphor::power::psu