#pragma once

#include "evdevpp/evdev.hpp"
#include "psensor.hpp"
#include "utility.hpp"

#include <sdeventplus/source/io.hpp>

#include <optional>

namespace phosphor
{
namespace fan
{
namespace presence
{
class RedundancyPolicy;

/**
 * @class Gpio
 * @brief Gpio presence sensor implementation.
 *
 * The Gpio class uses a gpio wire to determine presence state.
 */
class Gpio : public PresenceSensor
{
  public:
    /**
     * @brief
     *
     * Cannot move or copy due to this ptr as context
     * for sdevent callbacks.
     */
    Gpio() = delete;
    Gpio(const Gpio&) = delete;
    Gpio& operator=(const Gpio&) = delete;
    Gpio(Gpio&&) = delete;
    Gpio& operator=(Gpio&&) = delete;
    ~Gpio() = default;

    /**
     * @brief Construct a gpio sensor.
     *
     * @param[in] physDevice - The physical gpio device path.
     * @param[in] device - The gpio-keys input device.
     * @param[in] physPin - The physical gpio pin number.
     */
    Gpio(const std::string& physDevice, const std::string& device,
         unsigned int physPin);

    /**
     * @brief start
     *
     * Register for an sdevent io callback on the gpio.
     * Query the initial state of the gpio.
     *
     * @return The current sensor state.
     */
    bool start() override;

    /**
     * @brief stop
     *
     * De-register sdevent io callback.
     */
    void stop() override;

    /**
     * @brief fail
     *
     * Call the gpio out.
     */
    void fail() override;

    /**
     * @brief Check the sensor.
     *
     * Query the gpio.
     */
    bool present() override;

    /**
     * @brief Called when this presence sensor doesn't agree with other ones.
     *
     * @param[in] fanInventoryPath - The fan inventory D-Bus object path.
     */
    void logConflict(const std::string& fanInventoryPath) const override;

  private:
    /** @brief Get the policy associated with this sensor. */
    virtual RedundancyPolicy& getPolicy() = 0;

    /** @brief sdevent io callback. */
    void ioCallback();

    /** The current state of the sensor. */
    bool currentState;

    /** Gpio event device file descriptor. */
    util::FileDescriptor evdevfd;

    /** Gpio event device. */
    evdevpp::evdev::EvDev evdev;

    /** Physical gpio device. */
    std::string phys;

    /** Gpio pin number. */
    unsigned int pin;

    /** sdevent io handle. */
    std::optional<sdeventplus::source::IO> source;
};

/**
 * @class NullGpio
 * @brief a phony presence sensor implementation that always
 *        reports not-present. Used to keep fan-presence service
 *        running when hardware is offline.
 *
 */
class NullGpio : public PresenceSensor
{
  public:
    NullGpio() = default;

    /**
     * @brief start
     *
     * Required to conform to interface
     *
     * @return false [dummy implementation]
     */
    bool start() override
    {
        return false;
    }

    /**
     * @brief stop
     *
     * Required to conform to interface
     */
    void stop() override
    {}

    /**
     * @brief Check the sensor.
     *
     * @return false [dummy implementation]
     */
    bool present() override
    {
        return false;
    }

    /**
     * @brief Called when this presence sensor doesn't agree with other ones.
     *
     * @param[in] fanInventoryPath - The fan inventory D-Bus object path.
     */
    void logConflict(const std::string& fanInventoryPath) const override
    {}

  private:
    /**
     * @brief Required to conform to interface
     *
     */
    virtual RedundancyPolicy& getPolicy() = 0;
};

} // namespace presence
} // namespace fan
} // namespace phosphor
