#pragma once

#include "erase.hpp"
#include "util.hpp"

#include <stdplus/fd/create.hpp>
#include <stdplus/fd/managed.hpp>

#include <chrono>
#include <span>
#include <string>

namespace estoraged
{
using stdplus::fd::Fd;

class Pattern : public Erase
{
  public:
    /** @brief Creates a pattern erase object.
     *
     *  @param[in] inDevPath - the linux device path for the block device.
     */
    Pattern(std::string_view inDevPath) : Erase(inDevPath) {}

    /** @brief writes an incompressible random pattern to the drive, using
     * default parameters. It also throws errors accordingly.
     */
    void writePattern()
    {
        stdplus::fd::Fd&& fd =
            stdplus::fd::open(devPath, stdplus::fd::OpenAccess::WriteOnly);
        writePattern(util::findSizeOfBlockDevice(devPath), fd);
    }

    /** @brief writes an incompressible random pattern to the drive
     * and throws errors accordingly.
     *
     *  @param[in] bytes - Size of the block device
     *  @param[in] fd - the stdplus file descriptor
     */
    void writePattern(uint64_t driveSize, Fd& fd);

    /** @brief verifies the incompressible random pattern is on the drive, using
     * default parameters. It also throws errors accordingly.
     */
    void verifyPattern()
    {
        stdplus::fd::Fd&& fd =
            stdplus::fd::open(devPath, stdplus::fd::OpenAccess::ReadOnly);
        verifyPattern(util::findSizeOfBlockDevice(devPath), fd);
    }

    /** @brief verifies the incompressible random pattern is on the drive
     * and throws errors accordingly.
     *
     *  @param[in] bytes - Size of the block device
     *  @param[in] fd - the stdplus file descriptor
     */
    void verifyPattern(uint64_t driveSize, Fd& fd);

  private:
    static constexpr uint32_t seed = 0x6a656272;
    static constexpr size_t blockSize = 4096;
    static constexpr size_t blockSizeUsing32 = blockSize / sizeof(uint32_t);
    static constexpr size_t maxRetry = 32;
    static constexpr std::chrono::duration delay = std::chrono::milliseconds(1);
};

} // namespace estoraged
