1e12b181bSSunnySrivastava1984 #include "parser_factory.hpp" 2e12b181bSSunnySrivastava1984 36c71c9dcSSunny Srivastava #include "const.hpp" 46c71c9dcSSunny Srivastava #include "ibm_vpd_utils.hpp" 5e12b181bSSunnySrivastava1984 #include "ipz_parser.hpp" 66555e7efSjinuthomas #include "isdimm_vpd_parser.hpp" 7e12b181bSSunnySrivastava1984 #include "keyword_vpd_parser.hpp" 8e12b181bSSunnySrivastava1984 #include "memory_vpd_parser.hpp" 9dd453be9SSantosh Puranik #include "vpd_exceptions.hpp" 10e12b181bSSunnySrivastava1984 11e12b181bSSunnySrivastava1984 using namespace vpd::keyword::parser; 12e12b181bSSunnySrivastava1984 using namespace openpower::vpd::memory::parser; 135700b3c8Sjinuthomas using namespace openpower::vpd::isdimm::parser; 14e12b181bSSunnySrivastava1984 using namespace openpower::vpd::parser::interface; 15e12b181bSSunnySrivastava1984 using namespace openpower::vpd::ipz::parser; 16dd453be9SSantosh Puranik using namespace openpower::vpd::exceptions; 176c71c9dcSSunny Srivastava using namespace openpower::vpd::constants; 18e12b181bSSunnySrivastava1984 19e12b181bSSunnySrivastava1984 namespace openpower 20e12b181bSSunnySrivastava1984 { 21e12b181bSSunnySrivastava1984 namespace vpd 22e12b181bSSunnySrivastava1984 { 23e12b181bSSunnySrivastava1984 namespace parser 24e12b181bSSunnySrivastava1984 { 25e12b181bSSunnySrivastava1984 namespace factory 26e12b181bSSunnySrivastava1984 { getParser(const Binary & vpdVector,const std::string & inventoryPath,const std::string & vpdFilePath,uint32_t vpdStartOffset)27*18bb985cSgirikinterface::ParserInterface* ParserFactory::getParser( 28*18bb985cSgirik const Binary& vpdVector, const std::string& inventoryPath, 29*18bb985cSgirik const std::string& vpdFilePath, uint32_t vpdStartOffset) 30e12b181bSSunnySrivastava1984 { 31e12b181bSSunnySrivastava1984 vpdType type = vpdTypeCheck(vpdVector); 32e12b181bSSunnySrivastava1984 33e12b181bSSunnySrivastava1984 switch (type) 34e12b181bSSunnySrivastava1984 { 35e12b181bSSunnySrivastava1984 case IPZ_VPD: 36e12b181bSSunnySrivastava1984 { 37*18bb985cSgirik return new IpzVpdParser(vpdVector, inventoryPath, vpdFilePath, 38*18bb985cSgirik vpdStartOffset); 39e12b181bSSunnySrivastava1984 } 40e12b181bSSunnySrivastava1984 41e12b181bSSunnySrivastava1984 case KEYWORD_VPD: 42e12b181bSSunnySrivastava1984 { 4333c61c2dSPriyangaRamasamy return new KeywordVpdParser(vpdVector); 44e12b181bSSunnySrivastava1984 } 45e12b181bSSunnySrivastava1984 466555e7efSjinuthomas case DDR4_DDIMM_MEMORY_VPD: 476555e7efSjinuthomas case DDR5_DDIMM_MEMORY_VPD: 48e12b181bSSunnySrivastava1984 { 4933c61c2dSPriyangaRamasamy return new memoryVpdParser(vpdVector); 50e12b181bSSunnySrivastava1984 } 51e12b181bSSunnySrivastava1984 526555e7efSjinuthomas case DDR4_ISDIMM_MEMORY_VPD: 536555e7efSjinuthomas case DDR5_ISDIMM_MEMORY_VPD: 546555e7efSjinuthomas { 556555e7efSjinuthomas return new isdimmVpdParser(vpdVector); 566555e7efSjinuthomas } 576555e7efSjinuthomas 58e12b181bSSunnySrivastava1984 default: 59dd453be9SSantosh Puranik throw VpdDataException("Unable to determine VPD format"); 60e12b181bSSunnySrivastava1984 } 61e12b181bSSunnySrivastava1984 } 62e12b181bSSunnySrivastava1984 freeParser(interface::ParserInterface * parser)63e12b181bSSunnySrivastava1984void ParserFactory::freeParser(interface::ParserInterface* parser) 64e12b181bSSunnySrivastava1984 { 65e12b181bSSunnySrivastava1984 if (parser) 66e12b181bSSunnySrivastava1984 { 67e12b181bSSunnySrivastava1984 delete parser; 68e12b181bSSunnySrivastava1984 parser = nullptr; 69e12b181bSSunnySrivastava1984 } 70e12b181bSSunnySrivastava1984 } 71e12b181bSSunnySrivastava1984 72e12b181bSSunnySrivastava1984 } // namespace factory 73e12b181bSSunnySrivastava1984 } // namespace parser 74e12b181bSSunnySrivastava1984 } // namespace vpd 75e12b181bSSunnySrivastava1984 } // namespace openpower 76