utils: Add function to get the latest version

This repo does not know which PSU version is the latest, and it lets the
vendor tool to decide which one is the latest.

This commit defines PSU_VERSION_COMPARE_UTIL which is expected to be a
tool that accepts arguments of a list of versions, and returns the
latest version string.

Tested: Put and configure to use the example get_latest_version on
        Witherspoon, verify the versionId with a larger version string
        is returned.

Signed-off-by: Lei YU <mine260309@gmail.com>
Change-Id: Ic5a10d3724cf6a98b3979486c72d54f8deac7038
diff --git a/src/utils.hpp b/src/utils.hpp
index fe376a8..bb5f13f 100644
--- a/src/utils.hpp
+++ b/src/utils.hpp
@@ -2,6 +2,7 @@
 
 #include <experimental/any>
 #include <sdbusplus/bus.hpp>
+#include <set>
 #include <string>
 #include <vector>
 
@@ -82,6 +83,14 @@
  */
 std::string getVersion(const std::string& inventoryPath);
 
+/** @brief Get latest version from the PSU versions
+ *
+ * @param[in] versions - The list of the versions
+ *
+ * @return The latest version string
+ */
+std::string getLatestVersion(const std::set<std::string>& versions);
+
 /**
  * @brief The interface for utils
  */
@@ -107,6 +116,9 @@
 
     virtual std::string getVersion(const std::string& inventoryPath) const = 0;
 
+    virtual std::string
+        getLatestVersion(const std::set<std::string>& versions) const = 0;
+
     virtual any getPropertyImpl(sdbusplus::bus::bus& bus, const char* service,
                                 const char* path, const char* interface,
                                 const char* propertyName) const = 0;
@@ -140,6 +152,9 @@
 
     std::string getVersion(const std::string& inventoryPath) const override;
 
+    std::string
+        getLatestVersion(const std::set<std::string>& versions) const override;
+
     any getPropertyImpl(sdbusplus::bus::bus& bus, const char* service,
                         const char* path, const char* interface,
                         const char* propertyName) const override;
@@ -173,6 +188,11 @@
     return getUtils().getVersion(inventoryPath);
 }
 
+inline std::string getLatestVersion(const std::set<std::string>& versions)
+{
+    return getUtils().getLatestVersion(versions);
+}
+
 template <typename T>
 T getProperty(sdbusplus::bus::bus& bus, const char* service, const char* path,
               const char* interface, const char* propertyName)