oem-ibm: Builds filetable lazily

Adds support for lid files from file table to be patched when host is
off. FileTable is rebuilt when a getFileTable request is received.

Change-Id: Ief3afb698ba4fe8b871e85c9b7c9eff1e4699daa
Signed-off-by: Rahul D S <rahulds.rahul@gmail.com>
diff --git a/oem/ibm/libpldmresponder/file_table.cpp b/oem/ibm/libpldmresponder/file_table.cpp
index 402934b..9ea1286 100644
--- a/oem/ibm/libpldmresponder/file_table.cpp
+++ b/oem/ibm/libpldmresponder/file_table.cpp
@@ -129,14 +129,21 @@
     return table;
 }
 
+/** Single instance of filetable*/
+static FileTable fileTable;
+
 FileTable& buildFileTable(const std::string& fileTablePath)
 {
-    static FileTable table;
-    if (table.isEmpty())
+    if (fileTable.isEmpty())
     {
-        table = FileTable(fileTablePath);
+        fileTable = FileTable(fileTablePath);
     }
-    return table;
+    return fileTable;
+}
+
+void clearFileTable()
+{
+    fileTable.clear();
 }
 
 } // namespace filetable
diff --git a/oem/ibm/libpldmresponder/file_table.hpp b/oem/ibm/libpldmresponder/file_table.hpp
index 76ac959..4246589 100644
--- a/oem/ibm/libpldmresponder/file_table.hpp
+++ b/oem/ibm/libpldmresponder/file_table.hpp
@@ -121,5 +121,8 @@
 
 FileTable& buildFileTable(const std::string& fileTablePath);
 
+/** @brief Clear the file table instance */
+void clearFileTable();
+
 } // namespace filetable
 } // namespace pldm
diff --git a/oem/ibm/libpldmresponder/oem_ibm_handler.hpp b/oem/ibm/libpldmresponder/oem_ibm_handler.hpp
index 6c175aa..f859c1b 100644
--- a/oem/ibm/libpldmresponder/oem_ibm_handler.hpp
+++ b/oem/ibm/libpldmresponder/oem_ibm_handler.hpp
@@ -2,6 +2,7 @@
 
 #include "collect_slot_vpd.hpp"
 #include "common/utils.hpp"
+#include "file_table.hpp"
 #include "inband_code_update.hpp"
 #include "libpldmresponder/bios_config.hpp"
 #include "libpldmresponder/oem_handler.hpp"
@@ -92,6 +93,7 @@
                         setEventReceiverCnt = 0;
                         disableWatchDogTimer();
                         startStopTimer(false);
+                        pldm::filetable::clearFileTable();
                     }
                     else if (propVal ==
                              "xyz.openbmc_project.State.Host.HostState.Running")