Interface & Factory implementation for VPD Parsers
This commit abstracts the implementation logic of different parser.
A parser factory is implemented to provide instance of required
parser based on the type of vpd file needed to be parsed.
The interface should be derived to implement any further parser logic
related to vpd.
Status: This does not add any new function, so basic testing of
VPD parsing, VPD tool and writes was performed.
Signed-off-by: Sunny Srivastava <sunnsr25@in.ibm.com>
Change-Id: I3ce1a2d6b7e8d8984fd7800132e78ab8a9a21e56
diff --git a/vpd-parser/parser_factory.hpp b/vpd-parser/parser_factory.hpp
new file mode 100644
index 0000000..c66e42b
--- /dev/null
+++ b/vpd-parser/parser_factory.hpp
@@ -0,0 +1,47 @@
+#pragma once
+#include "parser_interface.hpp"
+#include "types.hpp"
+
+namespace openpower
+{
+namespace vpd
+{
+namespace parser
+{
+namespace factory
+{
+/** @class ParserFactory
+ * @brief Factory calss to instantiate concrete parser class.
+ *
+ * This class should be used to instantiate an instance of parser class based
+ * on the typeof vpd file.
+ */
+
+class ParserFactory
+{
+ public:
+ ParserFactory() = delete;
+ ~ParserFactory() = delete;
+ ParserFactory(const ParserFactory&) = delete;
+ ParserFactory& operator=(const ParserFactory&) = delete;
+ ParserFactory(ParserFactory&&) = delete;
+ ParserFactory& operator=(ParserFactory&&) = delete;
+
+ /**
+ * @brief A method to get object of concrete parser class.
+ * @param[in] - vpd file to check for the type.
+ * @return - Pointer to concrete parser class object.
+ */
+ static interface::ParserInterface* getParser(Binary&& vpdVector);
+
+ /**
+ * @brief A method to delete the parser object.
+ * @param[in] - Pointer to the parser object.
+ */
+ static void freeParser(interface::ParserInterface* parser);
+}; // ParserFactory
+
+} // namespace factory
+} // namespace parser
+} // namespace vpd
+} // namespace openpower
\ No newline at end of file