psu-ng: Move PSU validation logic to its own function

Move the PSU validation logic into a separate function so that it can be
called from additional places, such as the analyze() function, which
will check if the required PSUs are present before logging an error for
missing PSUs.
Also use std::count_if to get the number of present PSUs to make the
logic cleaner.

The only difference with the new function is that there's no difference
between a failure due to mismatched model names and failure due to
missing PSUs. The original logic would set the validation flag on
mismatched model names to not run again. The new scenario is that if EM
starts after psu-monitor and there is one or more PSUs with a mismatched
model name, then the same error will be created every time there's a new
EM PSU interface added.

Tested: Verified with debug logs that the validation logic remained the
same after the change.

Change-Id: Iced7afc34f566be1ce479c03639b780ecd7fdd53
Signed-off-by: Adriana Kobylak <anoo@us.ibm.com>
diff --git a/phosphor-power-supply/psu_manager.hpp b/phosphor-power-supply/psu_manager.hpp
index f1f1220..68dd091 100644
--- a/phosphor-power-supply/psu_manager.hpp
+++ b/phosphor-power-supply/psu_manager.hpp
@@ -240,6 +240,17 @@
     bool runValidateConfig = true;
 
     /**
+     * @brief Check that all PSUs have the same model name and that the system
+     * has the required number of PSUs present as specified in the Supported
+     * Configuration interface.
+     *
+     * @param[out] additionalData - Contains debug information on why the check
+     *             might have failed. Can be used to fill in error logs.
+     * @return true if all the required PSUs are present, false otherwise.
+     */
+    bool hasRequiredPSUs(std::map<std::string, std::string>& additionalData);
+
+    /**
      * @brief Map of supported PSU configurations that include the model name
      * and their properties.
      */