#pragma once

#include "const.hpp"
#include "parser_interface.hpp"
#include "store.hpp"
#include "types.hpp"

#include <vector>

namespace openpower
{
namespace vpd
{
namespace ipz
{
namespace parser
{

using ParserInterface = openpower::vpd::parser::interface::ParserInterface;
using kwdVpdMap = openpower::vpd::inventory::KeywordVpdMap;

class IpzVpdParser : public ParserInterface
{
  public:
    IpzVpdParser() = delete;
    IpzVpdParser(const IpzVpdParser&) = delete;
    IpzVpdParser& operator=(const IpzVpdParser&) = delete;
    IpzVpdParser(IpzVpdParser&&) = delete;
    IpzVpdParser& operator=(IpzVpdParser&&) = delete;
    ~IpzVpdParser() = default;

    /**
     * @brief Constructor
     * @param[in] - VpdVector - vpd buffer
     * @param[in] - path - Inventory Path
     * @param[in] - vpdFilePath - VPD H/w path
     * @param[in] - vpdStartOffset - VPD starting offset
     */
    IpzVpdParser(const Binary& VpdVector, const std::string& path,
                 const std::string& vpdFilePath, uint32_t vpdStartOffset) :
        vpd(VpdVector), inventoryPath(path), vpdFilePath(vpdFilePath),
        vpdStartOffset(vpdStartOffset)
    {}

    /**
     * @brief Parse the memory VPD binary data.
     * Collects and emplace the keyword-value pairs in map.
     *
     * @return map of keyword:value
     */
    std::variant<kwdVpdMap, Store> parse();

    /**
     * @brief An api to return interface name with respect to
     * the parser selected.
     *
     * @return - Interface name for that vpd type.
     */
    std::string getInterfaceName() const;

    /** @brief API to check vpd header
     *  @param [in] vpd - VPDheader in binary format
     */
    void processHeader();

  private:
    const Binary& vpd;

    /*Inventory path of the FRU */
    const std::string inventoryPath;

    /* VPD Path */
    const std::string vpdFilePath;

    /* Offset */
    uint32_t vpdStartOffset;

}; // class IpzVpdParser

} // namespace parser
} // namespace ipz
} // namespace vpd
} // namespace openpower
