#pragma once

#include <cstdint>
#include <memory>
#include <vector>

namespace ipmi_flash
{

/**
 * Each data transport mechanism must implement the DataInterface.
 */
class DataInterface
{
  public:
    virtual ~DataInterface() = default;

    /**
     * Initialize data transport mechanism.  Calling this should be idempotent
     * if possible.
     *
     * @return true if successful
     */
    virtual bool open() = 0;

    /**
     * Close the data transport mechanism.
     *
     * @return true if successful
     */
    virtual bool close() = 0;

    /**
     * Copy bytes from external interface (blocking call).
     *
     * @param[in] length - number of bytes to copy
     * @return the bytes read
     */
    virtual std::vector<std::uint8_t> copyFrom(std::uint32_t length) = 0;

    /**
     * set configuration.
     *
     * @param[in] configuration - byte vector of data.
     * @return bool - returns true on success.
     */
    virtual bool writeMeta(const std::vector<std::uint8_t>& configuration) = 0;

    /**
     * read configuration.
     *
     * @return bytes - whatever bytes are required configuration information for
     * the mechanism.
     */
    virtual std::vector<std::uint8_t> readMeta() = 0;
};

struct DataHandlerPack
{
    std::uint16_t bitmask;
    std::unique_ptr<DataInterface> handler;

    DataHandlerPack(std::uint16_t bitmask,
                    std::unique_ptr<DataInterface> handler) :
        bitmask(bitmask),
        handler(std::move(handler))
    {}

    /* Don't allow copying, assignment or move assignment, only moving. */
    DataHandlerPack(const DataHandlerPack&) = delete;
    DataHandlerPack& operator=(const DataHandlerPack&) = delete;
    DataHandlerPack(DataHandlerPack&&) = default;
    DataHandlerPack& operator=(DataHandlerPack&&) = delete;
};

} // namespace ipmi_flash
