pseq: Add getRails() method to device hierarchy

Add a method to get the voltage rails that are being enabled/monitored
by a power sequencer device.

Tested:
* Verified all gtests ran successfully

Change-Id: I04b3e9b0854c110858daf30dbf35dc44ab4ade0e
Signed-off-by: Shawn McCarney <shawnmm@us.ibm.com>
diff --git a/phosphor-power-sequencer/src/format_utils.hpp b/phosphor-power-sequencer/src/format_utils.hpp
index 327e518..b575f50 100644
--- a/phosphor-power-sequencer/src/format_utils.hpp
+++ b/phosphor-power-sequencer/src/format_utils.hpp
@@ -16,6 +16,7 @@
 #pragma once
 
 #include <format>
+#include <iterator>
 #include <span>
 #include <string>
 
diff --git a/phosphor-power-sequencer/src/power_sequencer_device.hpp b/phosphor-power-sequencer/src/power_sequencer_device.hpp
index 26e7c6a..f6ebb48 100644
--- a/phosphor-power-sequencer/src/power_sequencer_device.hpp
+++ b/phosphor-power-sequencer/src/power_sequencer_device.hpp
@@ -15,6 +15,7 @@
  */
 #pragma once
 
+#include "rail.hpp"
 #include "services.hpp"
 
 #include <cstdint>
@@ -51,6 +52,13 @@
     virtual const std::string& getName() const = 0;
 
     /**
+     * Returns the voltage rails that are enabled and monitored by this device.
+     *
+     * @return voltage rails
+     */
+    virtual const std::vector<std::unique_ptr<Rail>>& getRails() const = 0;
+
+    /**
      * Returns the GPIO values that can be read from the device.
      *
      * The vector indices correspond to the libgpiod line offsets.  For example,
@@ -127,6 +135,7 @@
      * Throws an exception if an error occurs while trying to obtain the status
      * of the rails.
      *
+     * @param services System services like hardware presence and the journal
      * @param powerSupplyError Power supply error that occurred before the pgood
      *                         fault.  Set to the empty string if no power
      *                         supply error occurred.  This error may be the
@@ -139,7 +148,8 @@
      *         device, false otherwise
      */
     virtual bool
-        hasPgoodFault(const std::string& powerSupplyError, std::string& error,
+        hasPgoodFault(Services& services, const std::string& powerSupplyError,
+                      std::string& error,
                       std::map<std::string, std::string>& additionalData) = 0;
 };
 
diff --git a/phosphor-power-sequencer/src/rail.cpp b/phosphor-power-sequencer/src/rail.cpp
index 7355b9a..18866c5 100644
--- a/phosphor-power-sequencer/src/rail.cpp
+++ b/phosphor-power-sequencer/src/rail.cpp
@@ -17,6 +17,7 @@
 #include "rail.hpp"
 
 #include "pmbus.hpp"
+#include "power_sequencer_device.hpp"
 
 #include <exception>
 #include <format>
diff --git a/phosphor-power-sequencer/src/rail.hpp b/phosphor-power-sequencer/src/rail.hpp
index 5a49e13..b4b6f95 100644
--- a/phosphor-power-sequencer/src/rail.hpp
+++ b/phosphor-power-sequencer/src/rail.hpp
@@ -15,7 +15,6 @@
  */
 #pragma once
 
-#include "power_sequencer_device.hpp"
 #include "services.hpp"
 
 #include <cstdint>
@@ -28,6 +27,9 @@
 namespace phosphor::power::sequencer
 {
 
+// Forward declarations to avoid circular dependencies
+class PowerSequencerDevice;
+
 /**
  * @struct GPIO
  *
diff --git a/phosphor-power-sequencer/test/mock_device.hpp b/phosphor-power-sequencer/test/mock_device.hpp
index 5bf09ea..01b60ff 100644
--- a/phosphor-power-sequencer/test/mock_device.hpp
+++ b/phosphor-power-sequencer/test/mock_device.hpp
@@ -39,13 +39,16 @@
     virtual ~MockDevice() = default;
 
     MOCK_METHOD(const std::string&, getName, (), (const, override));
+    MOCK_METHOD(const std::vector<std::unique_ptr<Rail>>&, getRails, (),
+                (const, override));
     MOCK_METHOD(std::vector<int>, getGPIOValues, (), (override));
     MOCK_METHOD(uint16_t, getStatusWord, (uint8_t page), (override));
     MOCK_METHOD(uint8_t, getStatusVout, (uint8_t page), (override));
     MOCK_METHOD(double, getReadVout, (uint8_t page), (override));
     MOCK_METHOD(double, getVoutUVFaultLimit, (uint8_t page), (override));
     MOCK_METHOD(bool, hasPgoodFault,
-                (const std::string& powerSupplyError, std::string& error,
+                (Services & services, const std::string& powerSupplyError,
+                 std::string& error,
                  (std::map<std::string, std::string> & additionalData)),
                 (override));
 };