SunnySrivastava1984 | e12b181 | 2020-05-26 02:23:11 -0500 | [diff] [blame] | 1 | #include "parser_factory.hpp" |
| 2 | |
Sunny Srivastava | 6c71c9d | 2021-04-15 04:43:54 -0500 | [diff] [blame] | 3 | #include "const.hpp" |
| 4 | #include "ibm_vpd_utils.hpp" |
SunnySrivastava1984 | e12b181 | 2020-05-26 02:23:11 -0500 | [diff] [blame] | 5 | #include "ipz_parser.hpp" |
jinuthomas | 6555e7e | 2023-02-14 21:48:00 -0600 | [diff] [blame] | 6 | #include "isdimm_vpd_parser.hpp" |
SunnySrivastava1984 | e12b181 | 2020-05-26 02:23:11 -0500 | [diff] [blame] | 7 | #include "keyword_vpd_parser.hpp" |
| 8 | #include "memory_vpd_parser.hpp" |
Santosh Puranik | dd453be | 2021-02-10 21:45:25 +0530 | [diff] [blame] | 9 | #include "vpd_exceptions.hpp" |
SunnySrivastava1984 | e12b181 | 2020-05-26 02:23:11 -0500 | [diff] [blame] | 10 | |
| 11 | using namespace vpd::keyword::parser; |
| 12 | using namespace openpower::vpd::memory::parser; |
jinuthomas | 5700b3c | 2023-03-07 22:51:00 -0600 | [diff] [blame] | 13 | using namespace openpower::vpd::isdimm::parser; |
SunnySrivastava1984 | e12b181 | 2020-05-26 02:23:11 -0500 | [diff] [blame] | 14 | using namespace openpower::vpd::parser::interface; |
| 15 | using namespace openpower::vpd::ipz::parser; |
Santosh Puranik | dd453be | 2021-02-10 21:45:25 +0530 | [diff] [blame] | 16 | using namespace openpower::vpd::exceptions; |
Sunny Srivastava | 6c71c9d | 2021-04-15 04:43:54 -0500 | [diff] [blame] | 17 | using namespace openpower::vpd::constants; |
SunnySrivastava1984 | e12b181 | 2020-05-26 02:23:11 -0500 | [diff] [blame] | 18 | |
| 19 | namespace openpower |
| 20 | { |
| 21 | namespace vpd |
| 22 | { |
| 23 | namespace parser |
| 24 | { |
| 25 | namespace factory |
| 26 | { |
girik | 18bb985 | 2022-11-16 05:48:13 -0600 | [diff] [blame] | 27 | interface::ParserInterface* ParserFactory::getParser( |
| 28 | const Binary& vpdVector, const std::string& inventoryPath, |
| 29 | const std::string& vpdFilePath, uint32_t vpdStartOffset) |
SunnySrivastava1984 | e12b181 | 2020-05-26 02:23:11 -0500 | [diff] [blame] | 30 | { |
| 31 | vpdType type = vpdTypeCheck(vpdVector); |
| 32 | |
| 33 | switch (type) |
| 34 | { |
| 35 | case IPZ_VPD: |
| 36 | { |
girik | 18bb985 | 2022-11-16 05:48:13 -0600 | [diff] [blame] | 37 | return new IpzVpdParser(vpdVector, inventoryPath, vpdFilePath, |
| 38 | vpdStartOffset); |
SunnySrivastava1984 | e12b181 | 2020-05-26 02:23:11 -0500 | [diff] [blame] | 39 | } |
| 40 | |
| 41 | case KEYWORD_VPD: |
| 42 | { |
PriyangaRamasamy | 33c61c2 | 2021-04-06 11:15:57 -0500 | [diff] [blame] | 43 | return new KeywordVpdParser(vpdVector); |
SunnySrivastava1984 | e12b181 | 2020-05-26 02:23:11 -0500 | [diff] [blame] | 44 | } |
| 45 | |
jinuthomas | 6555e7e | 2023-02-14 21:48:00 -0600 | [diff] [blame] | 46 | case DDR4_DDIMM_MEMORY_VPD: |
| 47 | case DDR5_DDIMM_MEMORY_VPD: |
SunnySrivastava1984 | e12b181 | 2020-05-26 02:23:11 -0500 | [diff] [blame] | 48 | { |
PriyangaRamasamy | 33c61c2 | 2021-04-06 11:15:57 -0500 | [diff] [blame] | 49 | return new memoryVpdParser(vpdVector); |
SunnySrivastava1984 | e12b181 | 2020-05-26 02:23:11 -0500 | [diff] [blame] | 50 | } |
| 51 | |
jinuthomas | 6555e7e | 2023-02-14 21:48:00 -0600 | [diff] [blame] | 52 | case DDR4_ISDIMM_MEMORY_VPD: |
| 53 | case DDR5_ISDIMM_MEMORY_VPD: |
| 54 | { |
| 55 | return new isdimmVpdParser(vpdVector); |
| 56 | } |
| 57 | |
SunnySrivastava1984 | e12b181 | 2020-05-26 02:23:11 -0500 | [diff] [blame] | 58 | default: |
Santosh Puranik | dd453be | 2021-02-10 21:45:25 +0530 | [diff] [blame] | 59 | throw VpdDataException("Unable to determine VPD format"); |
SunnySrivastava1984 | e12b181 | 2020-05-26 02:23:11 -0500 | [diff] [blame] | 60 | } |
| 61 | } |
| 62 | |
| 63 | void ParserFactory::freeParser(interface::ParserInterface* parser) |
| 64 | { |
| 65 | if (parser) |
| 66 | { |
| 67 | delete parser; |
| 68 | parser = nullptr; |
| 69 | } |
| 70 | } |
| 71 | |
| 72 | } // namespace factory |
| 73 | } // namespace parser |
| 74 | } // namespace vpd |
| 75 | } // namespace openpower |