psu-ng: Change the GPIOReader class to GPIOInterface

The GPIOReader class only contains a read function. A new write function
will be added so it makes sense for the class to be named Interface
instead of Reader.
Change GPIOReader to GPIOInterface, and change the base class from
GPIOInterface to GPIOInterfaceBase.

Tested: Ran CI.

Change-Id: I2a4abdabe0136a7f73337f0d054d2dd79712f53c
Signed-off-by: Adriana Kobylak <anoo@us.ibm.com>
diff --git a/phosphor-power-supply/power_supply.hpp b/phosphor-power-supply/power_supply.hpp
index f67d2a1..2660f32 100644
--- a/phosphor-power-supply/power_supply.hpp
+++ b/phosphor-power-supply/power_supply.hpp
@@ -65,7 +65,7 @@
         return *pmbusIntf;
     }
 
-    GPIOInterface* getPresenceGPIO()
+    GPIOInterfaceBase* getPresenceGPIO()
     {
         return presenceGPIO.get();
     }
@@ -292,7 +292,7 @@
     /**
      * @brief The libgpiod object for monitoring PSU presence
      */
-    std::unique_ptr<GPIOInterface> presenceGPIO = nullptr;
+    std::unique_ptr<GPIOInterfaceBase> presenceGPIO = nullptr;
 
     /** @brief True if the power supply is present. */
     bool present = false;
diff --git a/phosphor-power-supply/test/mock.cpp b/phosphor-power-supply/test/mock.cpp
index fc7d658..94a4911 100644
--- a/phosphor-power-supply/test/mock.cpp
+++ b/phosphor-power-supply/test/mock.cpp
@@ -32,9 +32,9 @@
     util.reset();
 }
 
-std::unique_ptr<GPIOInterface> createGPIO(const std::string& /*namedGpio*/)
+std::unique_ptr<GPIOInterfaceBase> createGPIO(const std::string& /*namedGpio*/)
 {
-    return std::make_unique<MockedGPIOReader>();
+    return std::make_unique<MockedGPIOInterface>();
 }
 
 } // namespace psu
diff --git a/phosphor-power-supply/test/mock.hpp b/phosphor-power-supply/test/mock.hpp
index d494e14..d354c9f 100644
--- a/phosphor-power-supply/test/mock.hpp
+++ b/phosphor-power-supply/test/mock.hpp
@@ -50,7 +50,7 @@
                 (const, override));
 };
 
-class MockedGPIOReader : public GPIOInterface
+class MockedGPIOInterface : public GPIOInterfaceBase
 {
   public:
     MOCK_METHOD(int, read, (), (override));
diff --git a/phosphor-power-supply/test/power_supply_tests.cpp b/phosphor-power-supply/test/power_supply_tests.cpp
index 19d5203..45999fb 100644
--- a/phosphor-power-supply/test/power_supply_tests.cpp
+++ b/phosphor-power-supply/test/power_supply_tests.cpp
@@ -130,8 +130,8 @@
     // getPresence().
 
     PowerSupply psu{bus, PSUInventoryPath, 4, 0x69, PSUGPIOLineName};
-    MockedGPIOReader* mockPresenceGPIO =
-        static_cast<MockedGPIOReader*>(psu.getPresenceGPIO());
+    MockedGPIOInterface* mockPresenceGPIO =
+        static_cast<MockedGPIOInterface*>(psu.getPresenceGPIO());
     EXPECT_CALL(*mockPresenceGPIO, read()).Times(1).WillOnce(Return(0));
 
     psu.analyze();
@@ -145,8 +145,8 @@
     PowerSupply psu2{bus, PSUInventoryPath, 5, 0x6a, PSUGPIOLineName};
     // In order to get the various faults tested, the power supply needs to
     // be present in order to read from the PMBus device(s).
-    MockedGPIOReader* mockPresenceGPIO2 =
-        static_cast<MockedGPIOReader*>(psu2.getPresenceGPIO());
+    MockedGPIOInterface* mockPresenceGPIO2 =
+        static_cast<MockedGPIOInterface*>(psu2.getPresenceGPIO());
     ON_CALL(*mockPresenceGPIO2, read()).WillByDefault(Return(1));
 
     EXPECT_EQ(psu2.isPresent(), false);
@@ -241,8 +241,8 @@
         // Assume GPIO presence, not inventory presence?
         PowerSupply psu{bus, PSUInventoryPath, 4, 0x69, PSUGPIOLineName};
 
-        MockedGPIOReader* mockPresenceGPIO =
-            static_cast<MockedGPIOReader*>(psu.getPresenceGPIO());
+        MockedGPIOInterface* mockPresenceGPIO =
+            static_cast<MockedGPIOInterface*>(psu.getPresenceGPIO());
         ON_CALL(*mockPresenceGPIO, read()).WillByDefault(Return(0));
         MockedPMBus& mockPMBus = static_cast<MockedPMBus&>(psu.getPMBus());
         // Constructor should set initial presence, default read returns 0.
@@ -258,8 +258,8 @@
     {
         // Assume GPIO presence, not inventory presence?
         PowerSupply psu{bus, PSUInventoryPath, 5, 0x6a, PSUGPIOLineName};
-        MockedGPIOReader* mockPresenceGPIO =
-            static_cast<MockedGPIOReader*>(psu.getPresenceGPIO());
+        MockedGPIOInterface* mockPresenceGPIO =
+            static_cast<MockedGPIOInterface*>(psu.getPresenceGPIO());
         ON_CALL(*mockPresenceGPIO, read()).WillByDefault(Return(1));
         MockedPMBus& mockPMBus = static_cast<MockedPMBus&>(psu.getPMBus());
         // TODO: expect setPresence call?
@@ -279,8 +279,8 @@
 {
     auto bus = sdbusplus::bus::new_default();
     PowerSupply psu{bus, PSUInventoryPath, 13, 0x68, PSUGPIOLineName};
-    MockedGPIOReader* mockPresenceGPIO =
-        static_cast<MockedGPIOReader*>(psu.getPresenceGPIO());
+    MockedGPIOInterface* mockPresenceGPIO =
+        static_cast<MockedGPIOInterface*>(psu.getPresenceGPIO());
     // GPIO read return 1 to indicate present.
     ON_CALL(*mockPresenceGPIO, read()).WillByDefault(Return(1));
     MockedPMBus& mockPMBus = static_cast<MockedPMBus&>(psu.getPMBus());
@@ -334,8 +334,8 @@
     try
     {
         PowerSupply psu{bus, PSUInventoryPath, 13, 0x69, PSUGPIOLineName};
-        MockedGPIOReader* mockPresenceGPIO =
-            static_cast<MockedGPIOReader*>(psu.getPresenceGPIO());
+        MockedGPIOInterface* mockPresenceGPIO =
+            static_cast<MockedGPIOInterface*>(psu.getPresenceGPIO());
         // GPIO read return 1 to indicate present.
         EXPECT_CALL(*mockPresenceGPIO, read()).Times(1).WillOnce(Return(1));
         psu.analyze();
@@ -366,8 +366,8 @@
     auto bus = sdbusplus::bus::new_default();
 
     PowerSupply psu{bus, PSUInventoryPath, 3, 0x68, PSUGPIOLineName};
-    MockedGPIOReader* mockPresenceGPIO =
-        static_cast<MockedGPIOReader*>(psu.getPresenceGPIO());
+    MockedGPIOInterface* mockPresenceGPIO =
+        static_cast<MockedGPIOInterface*>(psu.getPresenceGPIO());
     EXPECT_EQ(psu.isPresent(), false);
 
     // Change GPIO read to return 1 to indicate present.
@@ -381,8 +381,8 @@
     auto bus = sdbusplus::bus::new_default();
 
     PowerSupply psu{bus, PSUInventoryPath, 11, 0x6f, PSUGPIOLineName};
-    MockedGPIOReader* mockPresenceGPIO =
-        static_cast<MockedGPIOReader*>(psu.getPresenceGPIO());
+    MockedGPIOInterface* mockPresenceGPIO =
+        static_cast<MockedGPIOInterface*>(psu.getPresenceGPIO());
     // Always return 1 to indicate present.
     EXPECT_CALL(*mockPresenceGPIO, read()).WillRepeatedly(Return(1));
     psu.analyze();
@@ -401,8 +401,8 @@
     auto bus = sdbusplus::bus::new_default();
 
     PowerSupply psu{bus, PSUInventoryPath, 3, 0x68, PSUGPIOLineName};
-    MockedGPIOReader* mockPresenceGPIO =
-        static_cast<MockedGPIOReader*>(psu.getPresenceGPIO());
+    MockedGPIOInterface* mockPresenceGPIO =
+        static_cast<MockedGPIOInterface*>(psu.getPresenceGPIO());
     // Always return 1 to indicate present.
     EXPECT_CALL(*mockPresenceGPIO, read()).WillRepeatedly(Return(1));
     psu.analyze();
@@ -427,8 +427,8 @@
     auto bus = sdbusplus::bus::new_default();
 
     PowerSupply psu{bus, PSUInventoryPath, 3, 0x68, PSUGPIOLineName};
-    MockedGPIOReader* mockPresenceGPIO =
-        static_cast<MockedGPIOReader*>(psu.getPresenceGPIO());
+    MockedGPIOInterface* mockPresenceGPIO =
+        static_cast<MockedGPIOInterface*>(psu.getPresenceGPIO());
     // Always return 1 to indicate present.
     EXPECT_CALL(*mockPresenceGPIO, read()).WillRepeatedly(Return(1));
     psu.analyze();
@@ -453,8 +453,8 @@
     auto bus = sdbusplus::bus::new_default();
 
     PowerSupply psu{bus, PSUInventoryPath, 3, 0x68, PSUGPIOLineName};
-    MockedGPIOReader* mockPresenceGPIO =
-        static_cast<MockedGPIOReader*>(psu.getPresenceGPIO());
+    MockedGPIOInterface* mockPresenceGPIO =
+        static_cast<MockedGPIOInterface*>(psu.getPresenceGPIO());
     // Always return 1 to indicate present.
     EXPECT_CALL(*mockPresenceGPIO, read()).WillRepeatedly(Return(1));
     psu.analyze();
diff --git a/phosphor-power-supply/util.cpp b/phosphor-power-supply/util.cpp
index 858d1a3..41a7109 100644
--- a/phosphor-power-supply/util.cpp
+++ b/phosphor-power-supply/util.cpp
@@ -11,7 +11,7 @@
     return util;
 }
 
-GPIOReader::GPIOReader(const std::string& namedGpio)
+GPIOInterface::GPIOInterface(const std::string& namedGpio)
 {
     try
     {
@@ -29,18 +29,18 @@
     }
 }
 
-std::unique_ptr<GPIOInterface>
-    GPIOReader::createGPIO(const std::string& namedGpio)
+std::unique_ptr<GPIOInterfaceBase>
+    GPIOInterface::createGPIO(const std::string& namedGpio)
 {
-    return std::make_unique<GPIOReader>(namedGpio);
+    return std::make_unique<GPIOInterface>(namedGpio);
 }
 
-std::string GPIOReader::getName() const
+std::string GPIOInterface::getName() const
 {
     return line.name();
 }
 
-int GPIOReader::read()
+int GPIOInterface::read()
 {
     using namespace phosphor::logging;
 
@@ -81,9 +81,9 @@
     return value;
 }
 
-std::unique_ptr<GPIOInterface> createGPIO(const std::string& namedGpio)
+std::unique_ptr<GPIOInterfaceBase> createGPIO(const std::string& namedGpio)
 {
-    return GPIOReader::createGPIO(namedGpio);
+    return GPIOInterface::createGPIO(namedGpio);
 }
 
 } // namespace phosphor::power::psu
diff --git a/phosphor-power-supply/util.hpp b/phosphor-power-supply/util.hpp
index da04020..ca0bf3c 100644
--- a/phosphor-power-supply/util.hpp
+++ b/phosphor-power-supply/util.hpp
@@ -89,26 +89,26 @@
     }
 };
 
-std::unique_ptr<GPIOInterface> createGPIO(const std::string& namedGpio);
+std::unique_ptr<GPIOInterfaceBase> createGPIO(const std::string& namedGpio);
 
-class GPIOReader : public GPIOInterface
+class GPIOInterface : public GPIOInterfaceBase
 {
   public:
-    GPIOReader() = delete;
-    virtual ~GPIOReader() = default;
-    GPIOReader(const GPIOReader&) = default;
-    GPIOReader& operator=(const GPIOReader&) = default;
-    GPIOReader(GPIOReader&&) = default;
-    GPIOReader& operator=(GPIOReader&&) = default;
+    GPIOInterface() = delete;
+    virtual ~GPIOInterface() = default;
+    GPIOInterface(const GPIOInterface&) = default;
+    GPIOInterface& operator=(const GPIOInterface&) = default;
+    GPIOInterface(GPIOInterface&&) = default;
+    GPIOInterface& operator=(GPIOInterface&&) = default;
 
     /**
      * Constructor
      *
      * @param[in] namedGpio - The string for the gpio-line-name
      */
-    GPIOReader(const std::string& namedGpio);
+    GPIOInterface(const std::string& namedGpio);
 
-    static std::unique_ptr<GPIOInterface>
+    static std::unique_ptr<GPIOInterfaceBase>
         createGPIO(const std::string& namedGpio);
 
     /**
diff --git a/phosphor-power-supply/util_base.hpp b/phosphor-power-supply/util_base.hpp
index 7ae362c..ade43ef 100644
--- a/phosphor-power-supply/util_base.hpp
+++ b/phosphor-power-supply/util_base.hpp
@@ -37,10 +37,10 @@
     return getUtils().setPresence(bus, invpath, present, name);
 }
 
-class GPIOInterface
+class GPIOInterfaceBase
 {
   public:
-    virtual ~GPIOInterface() = default;
+    virtual ~GPIOInterfaceBase() = default;
 
     virtual int read() = 0;
     virtual std::string getName() const = 0;