1 #pragma once
2 
3 namespace phosphor::fan::monitor
4 {
5 
6 /**
7  * @class PowerInterfaceBase
8  *
9  * The base class that contains the APIs to do power offs.
10  * This is required so it can be mocked in testcases.
11  */
12 class PowerInterfaceBase
13 {
14   public:
15     PowerInterfaceBase() = default;
16     virtual ~PowerInterfaceBase() = default;
17     PowerInterfaceBase(const PowerInterfaceBase&) = delete;
18     PowerInterfaceBase& operator=(const PowerInterfaceBase&) = delete;
19     PowerInterfaceBase(PowerInterfaceBase&&) = delete;
20     PowerInterfaceBase& operator=(PowerInterfaceBase&&) = delete;
21 
22     /**
23      * @brief Perform a soft power off
24      */
25     virtual void softPowerOff() = 0;
26 
27     /**
28      * @brief Perform a hard power off
29      */
30     virtual void hardPowerOff() = 0;
31 };
32 
33 /**
34  * @class PowerInterface
35  *
36  * Concrete class to perform power offs
37  */
38 class PowerInterface : public PowerInterfaceBase
39 {
40   public:
41     PowerInterface() = default;
42     ~PowerInterface() = default;
43     PowerInterface(const PowerInterface&) = delete;
44     PowerInterface& operator=(const PowerInterface&) = delete;
45     PowerInterface(PowerInterface&&) = delete;
46     PowerInterface& operator=(PowerInterface&&) = delete;
47 
48     /**
49      * @brief Perform a soft power off
50      */
51     void softPowerOff() override;
52 
53     /**
54      * @brief Perform a hard power off
55      */
56     void hardPowerOff() override;
57 };
58 
59 } // namespace phosphor::fan::monitor
60