#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
