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 | { |
Sunny Srivastava | f31a91b | 2022-06-09 08:11:29 -0500 | [diff] [blame] | 27 | interface::ParserInterface* |
| 28 | ParserFactory::getParser(const Binary& vpdVector, |
| 29 | const std::string& inventoryPath) |
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 | { |
Sunny Srivastava | f31a91b | 2022-06-09 08:11:29 -0500 | [diff] [blame] | 37 | return new IpzVpdParser(vpdVector, inventoryPath); |
SunnySrivastava1984 | e12b181 | 2020-05-26 02:23:11 -0500 | [diff] [blame] | 38 | } |
| 39 | |
| 40 | case KEYWORD_VPD: |
| 41 | { |
PriyangaRamasamy | 33c61c2 | 2021-04-06 11:15:57 -0500 | [diff] [blame] | 42 | return new KeywordVpdParser(vpdVector); |
SunnySrivastava1984 | e12b181 | 2020-05-26 02:23:11 -0500 | [diff] [blame] | 43 | } |
| 44 | |
jinuthomas | 6555e7e | 2023-02-14 21:48:00 -0600 | [diff] [blame] | 45 | case DDR4_DDIMM_MEMORY_VPD: |
| 46 | case DDR5_DDIMM_MEMORY_VPD: |
SunnySrivastava1984 | e12b181 | 2020-05-26 02:23:11 -0500 | [diff] [blame] | 47 | { |
PriyangaRamasamy | 33c61c2 | 2021-04-06 11:15:57 -0500 | [diff] [blame] | 48 | return new memoryVpdParser(vpdVector); |
SunnySrivastava1984 | e12b181 | 2020-05-26 02:23:11 -0500 | [diff] [blame] | 49 | } |
| 50 | |
jinuthomas | 6555e7e | 2023-02-14 21:48:00 -0600 | [diff] [blame] | 51 | case DDR4_ISDIMM_MEMORY_VPD: |
| 52 | case DDR5_ISDIMM_MEMORY_VPD: |
| 53 | { |
| 54 | return new isdimmVpdParser(vpdVector); |
| 55 | } |
| 56 | |
SunnySrivastava1984 | e12b181 | 2020-05-26 02:23:11 -0500 | [diff] [blame] | 57 | default: |
Santosh Puranik | dd453be | 2021-02-10 21:45:25 +0530 | [diff] [blame] | 58 | throw VpdDataException("Unable to determine VPD format"); |
SunnySrivastava1984 | e12b181 | 2020-05-26 02:23:11 -0500 | [diff] [blame] | 59 | } |
| 60 | } |
| 61 | |
| 62 | void ParserFactory::freeParser(interface::ParserInterface* parser) |
| 63 | { |
| 64 | if (parser) |
| 65 | { |
| 66 | delete parser; |
| 67 | parser = nullptr; |
| 68 | } |
| 69 | } |
| 70 | |
| 71 | } // namespace factory |
| 72 | } // namespace parser |
| 73 | } // namespace vpd |
| 74 | } // namespace openpower |