Move single FAB API under the separate class

SingleFab class provides functionalities to support single FAB feature.
This commit moves the single FAB related API under SingleFab class.

Change-Id: I8d55cd2134f5812f83f5fc5033df097ab1b1f8f2
Signed-off-by: Anupama B R <anupama.b.r1@ibm.com>
diff --git a/vpd-manager/src/single_fab.cpp b/vpd-manager/src/single_fab.cpp
new file mode 100644
index 0000000..9b2045c
--- /dev/null
+++ b/vpd-manager/src/single_fab.cpp
@@ -0,0 +1,49 @@
+#include "single_fab.hpp"
+
+#include "constants.hpp"
+#include "types.hpp"
+
+#include <utility/json_utility.hpp>
+
+namespace vpd
+{
+constexpr auto pimPersistVsbpPath =
+    "/var/lib/phosphor-inventory-manager/xyz/openbmc_project/inventory/system/chassis/motherboard/com.ibm.ipzvpd.VSBP";
+
+std::string SingleFab::getImFromPersistedLocation() const noexcept
+{
+    try
+    {
+        auto l_parsedVsbpJsonObj =
+            jsonUtility::getParsedJson(pimPersistVsbpPath);
+        if (!l_parsedVsbpJsonObj.contains("value0") ||
+            !l_parsedVsbpJsonObj["value0"].contains(constants::kwdIM) ||
+            !l_parsedVsbpJsonObj["value0"][constants::kwdIM].is_array())
+        {
+            throw std::runtime_error(
+                "Json is empty or mandatory tag(s) missing from JSON");
+        }
+
+        const types::BinaryVector l_imValue =
+            l_parsedVsbpJsonObj["value0"][constants::kwdIM]
+                .get<types::BinaryVector>();
+
+        std::ostringstream l_imData;
+        for (const auto& l_byte : l_imValue)
+        {
+            l_imData << std::setw(2) << std::setfill('0') << std::hex
+                     << static_cast<int>(l_byte);
+        }
+        return l_imData.str();
+    }
+    catch (const std::exception& l_ex)
+    {
+        logging::logMessage(
+            "Error while getting IM value from PIM persisted file: " +
+            std::string(pimPersistVsbpPath) +
+            ", reason: " + std::string(l_ex.what()));
+    }
+
+    return std::string();
+}
+} // namespace vpd