blob: 22e5d3b0fd1b91010482d588eb9e34100a385395 [file] [log] [blame]
#pragma once
#include "logger.hpp"
#include "parser_interface.hpp"
#include "types.hpp"
#include <memory>
namespace vpd
{
/**
* @brief Factory calss to instantiate concrete parser class.
*
* This class should be used to instantiate an instance of parser class based
* on the type of vpd file.
*/
class ParserFactory
{
public:
// Deleted APIs
ParserFactory() = delete;
~ParserFactory() = delete;
ParserFactory(const ParserFactory&) = delete;
ParserFactory& operator=(const ParserFactory&) = delete;
ParserFactory(ParserFactory&&) = delete;
ParserFactory& operator=(ParserFactory&&) = delete;
/**
* @brief An API to get object of concrete parser class.
*
* The method is used to get object of respective parser class based on the
* type of VPD extracted from VPD vector passed to the API.
* To detect respective parser from VPD vector, add logic into the API
* vpdTypeCheck.
*
* Note: API throws DataException in case vpd type check fails for any
* unknown type. Caller responsibility to handle the exception.
*
* @param[in] i_vpdVector - vpd file content to check for the type.
* @param[in] i_vpdFilePath - FRU EEPROM path.
* @param[in] i_vpdStartOffset - Offset from where VPD starts in the VPD
* file.
*
* @return - Pointer to concrete parser class object.
*/
static std::shared_ptr<ParserInterface> getParser(
const types::BinaryVector& i_vpdVector,
const std::string& i_vpdFilePath, size_t i_vpdStartOffset);
};
} // namespace vpd