1 #include "parser_factory.hpp" 2 3 #include "const.hpp" 4 #include "ibm_vpd_utils.hpp" 5 #include "ipz_parser.hpp" 6 #include "isdimm_vpd_parser.hpp" 7 #include "keyword_vpd_parser.hpp" 8 #include "memory_vpd_parser.hpp" 9 #include "vpd_exceptions.hpp" 10 11 using namespace vpd::keyword::parser; 12 using namespace openpower::vpd::memory::parser; 13 using namespace openpower::vpd::isdimm::parser; 14 using namespace openpower::vpd::parser::interface; 15 using namespace openpower::vpd::ipz::parser; 16 using namespace openpower::vpd::exceptions; 17 using namespace openpower::vpd::constants; 18 19 namespace openpower 20 { 21 namespace vpd 22 { 23 namespace parser 24 { 25 namespace factory 26 { getParser(const Binary & vpdVector,const std::string & inventoryPath,const std::string & vpdFilePath,uint32_t vpdStartOffset)27interface::ParserInterface* ParserFactory::getParser( 28 const Binary& vpdVector, const std::string& inventoryPath, 29 const std::string& vpdFilePath, uint32_t vpdStartOffset) 30 { 31 vpdType type = vpdTypeCheck(vpdVector); 32 33 switch (type) 34 { 35 case IPZ_VPD: 36 { 37 return new IpzVpdParser(vpdVector, inventoryPath, vpdFilePath, 38 vpdStartOffset); 39 } 40 41 case KEYWORD_VPD: 42 { 43 return new KeywordVpdParser(vpdVector); 44 } 45 46 case DDR4_DDIMM_MEMORY_VPD: 47 case DDR5_DDIMM_MEMORY_VPD: 48 { 49 return new memoryVpdParser(vpdVector); 50 } 51 52 case DDR4_ISDIMM_MEMORY_VPD: 53 case DDR5_ISDIMM_MEMORY_VPD: 54 { 55 return new isdimmVpdParser(vpdVector); 56 } 57 58 default: 59 throw VpdDataException("Unable to determine VPD format"); 60 } 61 } 62 freeParser(interface::ParserInterface * parser)63void 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 76