1 #pragma once
2 
3 #include "types.hpp"
4 
5 #include <sdbusplus/bus/match.hpp>
6 
7 #include <bitset>
8 
9 namespace phosphor::power::psu
10 {
11 
12 /**
13  * @class UtilBase
14  * A base class to allow for mocking certain utility functions.
15  */
16 class UtilBase
17 {
18   public:
19     virtual ~UtilBase() = default;
20 
21     virtual bool getPresence(sdbusplus::bus::bus& bus,
22                              const std::string& invpath) const = 0;
23 
24     virtual void setPresence(sdbusplus::bus::bus& bus,
25                              const std::string& invpath, bool present,
26                              const std::string& name) const = 0;
27 
28     virtual void setAvailable(sdbusplus::bus::bus& bus,
29                               const std::string& invpath,
30                               bool available) const = 0;
31 
32     virtual void handleChassisHealthRollup(sdbusplus::bus::bus& bus,
33                                            const std::string& invpath,
34                                            bool addRollup) const = 0;
35 };
36 
37 const UtilBase& getUtils();
38 
39 inline bool getPresence(sdbusplus::bus::bus& bus, const std::string& invpath)
40 {
41     return getUtils().getPresence(bus, invpath);
42 }
43 
44 inline void setPresence(sdbusplus::bus::bus& bus, const std::string& invpath,
45                         bool present, const std::string& name)
46 {
47     return getUtils().setPresence(bus, invpath, present, name);
48 }
49 
50 inline void setAvailable(sdbusplus::bus::bus& bus, const std::string& invpath,
51                          bool available)
52 {
53     getUtils().setAvailable(bus, invpath, available);
54 }
55 
56 inline void handleChassisHealthRollup(sdbusplus::bus::bus& bus,
57                                       const std::string& invpath,
58                                       bool addRollup)
59 {
60     getUtils().handleChassisHealthRollup(bus, invpath, addRollup);
61 }
62 
63 class GPIOInterfaceBase
64 {
65   public:
66     virtual ~GPIOInterfaceBase() = default;
67 
68     virtual int read() = 0;
69     virtual void write(int value, std::bitset<32> flags) = 0;
70     virtual std::string getName() const = 0;
71 };
72 
73 } // namespace phosphor::power::psu
74