#include <exception>
#include <algorithm>
#include "defines.hpp"
#include "write.hpp"
#include "writefru.hpp"

namespace openpower
{
namespace vpd
{
namespace inventory
{

static const std::unordered_map<std::string, Fru> supportedFrus =
{
    {"BMC", Fru::BMC},
    {"ETHERNET", Fru::ETHERNET}
};

void write(const std::string& type,
           const Store& vpdStore,
           const std::string& path)
{
    // Get the enum corresponding to type, and call
    // appropriate write FRU method.

    std::string fru = type;
    std::transform(fru.begin(), fru.end(), fru.begin(),
                   [](unsigned char c) { return std::toupper(c); });
    auto iterator = supportedFrus.find(fru);
    if (supportedFrus.end() == iterator)
    {
        throw std::runtime_error("Unsupported FRU: " + std::move(fru));
    }
    else
    {
        switch (iterator->second)
        {
            case Fru::BMC:
            {
                writeFru<Fru::BMC>(vpdStore, path);
                break;
            }

            case Fru::ETHERNET:
            {
                writeFru<Fru::ETHERNET>(vpdStore, path);
                break;
            }

            default:
                break;
        }
    }
}

} // inventory
} // namespace vpd
} // namespace openpower
