Revamped code for VPD parser
The commit removes all the pre-existing code from the branch
and pushes the revamped code.
Major modification includes:
- Movement from multi exe to single daemon model.
- Multithreaded approach to parse FRU VPD.
- Better error handling.
- Refactored code for performance optimization.
Note: This code supports all the existing functionalities as it is.
Change-Id: I1ddce1f0725ac59020b72709689a1013643bda8b
Signed-off-by: Sunny Srivastava <sunnsr25@in.ibm.com>
diff --git a/vpd-manager/include/parser_factory.hpp b/vpd-manager/include/parser_factory.hpp
new file mode 100644
index 0000000..819ec59
--- /dev/null
+++ b/vpd-manager/include/parser_factory.hpp
@@ -0,0 +1,50 @@
+#pragma once
+
+#include "logger.hpp"
+#include "parser_interface.hpp"
+#include "types.hpp"
+
+#include <memory>
+
+namespace vpd
+{
+/**
+ * @brief Factory calss to instantiate concrete parser class.
+ *
+ * This class should be used to instantiate an instance of parser class based
+ * on the type of vpd file.
+ */
+class ParserFactory
+{
+ public:
+ // Deleted APIs
+ ParserFactory() = delete;
+ ~ParserFactory() = delete;
+ ParserFactory(const ParserFactory&) = delete;
+ ParserFactory& operator=(const ParserFactory&) = delete;
+ ParserFactory(ParserFactory&&) = delete;
+ ParserFactory& operator=(ParserFactory&&) = delete;
+
+ /**
+ * @brief An API to get object of concrete parser class.
+ *
+ * The method is used to get object of respective parser class based on the
+ * type of VPD extracted from VPD vector passed to the API.
+ * To detect respective parser from VPD vector, add logic into the API
+ * vpdTypeCheck.
+ *
+ * Note: API throws DataException in case vpd type check fails for any
+ * unknown type. Caller responsibility to handle the exception.
+ *
+ * @param[in] i_vpdVector - vpd file content to check for the type.
+ * @param[in] i_vpdFilePath - FRU EEPROM path.
+ * @param[in] i_vpdStartOffset - Offset from where VPD starts in the VPD
+ * file.
+ *
+ * @return - Pointer to concrete parser class object.
+ */
+ static std::shared_ptr<ParserInterface>
+ getParser(const types::BinaryVector& i_vpdVector,
+ const std::string& i_vpdFilePath, size_t i_vpdStartOffset);
+};
+} // namespace vpd