blob: 22e5d3b0fd1b91010482d588eb9e34100a385395 [file] [log] [blame]
Sunny Srivastavafa5e4d32023-03-12 11:59:49 -05001#pragma once
2
3#include "logger.hpp"
4#include "parser_interface.hpp"
5#include "types.hpp"
6
7#include <memory>
8
9namespace vpd
10{
11/**
12 * @brief Factory calss to instantiate concrete parser class.
13 *
14 * This class should be used to instantiate an instance of parser class based
15 * on the type of vpd file.
16 */
17class ParserFactory
18{
19 public:
20 // Deleted APIs
21 ParserFactory() = delete;
22 ~ParserFactory() = delete;
23 ParserFactory(const ParserFactory&) = delete;
24 ParserFactory& operator=(const ParserFactory&) = delete;
25 ParserFactory(ParserFactory&&) = delete;
26 ParserFactory& operator=(ParserFactory&&) = delete;
27
28 /**
29 * @brief An API to get object of concrete parser class.
30 *
31 * The method is used to get object of respective parser class based on the
32 * type of VPD extracted from VPD vector passed to the API.
33 * To detect respective parser from VPD vector, add logic into the API
34 * vpdTypeCheck.
35 *
36 * Note: API throws DataException in case vpd type check fails for any
37 * unknown type. Caller responsibility to handle the exception.
38 *
39 * @param[in] i_vpdVector - vpd file content to check for the type.
40 * @param[in] i_vpdFilePath - FRU EEPROM path.
41 * @param[in] i_vpdStartOffset - Offset from where VPD starts in the VPD
42 * file.
43 *
44 * @return - Pointer to concrete parser class object.
45 */
Patrick Williams43fedab2025-02-03 14:28:05 -050046 static std::shared_ptr<ParserInterface> getParser(
47 const types::BinaryVector& i_vpdVector,
48 const std::string& i_vpdFilePath, size_t i_vpdStartOffset);
Sunny Srivastavafa5e4d32023-03-12 11:59:49 -050049};
50} // namespace vpd