#pragma once

#include "eeprom_device.hpp"
#include "fan.hpp"

namespace phosphor
{
namespace fan
{
namespace presence
{

class PresenceSensor;

/**
 * @class RedundancyPolicy
 * @brief Redundancy policy interface.
 *
 * Provide concrete implementations of RedundancyPolicy to realize
 * new redundancy logic.
 *
 * A fan can have multiple ways to detect whether or not it is present.
 * The redundancy policy encapsulates the logic to aggregate those
 * inputs into a single yes or no the fan is present.
 */
class RedundancyPolicy
{
  public:
    RedundancyPolicy(const RedundancyPolicy&) = default;
    RedundancyPolicy& operator=(const RedundancyPolicy&) = default;
    RedundancyPolicy(RedundancyPolicy&&) = default;
    RedundancyPolicy& operator=(RedundancyPolicy&&) = default;
    virtual ~RedundancyPolicy() = default;

    /**
     * @brief Construct a new Redundancy Policy.
     *
     * @param[in] fan - The fan associated with this policy.
     * @param[in] eeprom - EEPROM device instance
     */
    explicit RedundancyPolicy(const Fan& f,
                              std::unique_ptr<EEPROMDevice> eeprom) :
        fan(f),
        eepromDevice(std::move(eeprom))
    {}

    /**
     * @brief stateChanged
     *
     * Typically invoked by presence sensors to signify
     * a change of presence.  Implementations should update
     * the inventory and execute their policy logic.
     *
     * @param[in] present - The new state of the sensor.
     * @param[in] sensor - The sensor that changed state.
     */
    virtual void stateChanged(bool present, PresenceSensor& sensor) = 0;

    /**
     * @brief monitor
     *
     * Implementations should start monitoring the sensors
     * associated with the fan.
     */
    virtual void monitor() = 0;

  protected:
    /** @brief Fan name and inventory path. */
    const Fan& fan;

    /**
     * @brief Handles binding the EEPROM driver on fan plug
     *        if configured to do so.
     */
    std::unique_ptr<EEPROMDevice> eepromDevice;
};

/**
 * @class PolicyAccess
 * @brief Policy association.
 *
 * PolicyAccess can be used to associate a redundancy policy
 * with something else.
 *
 * Wrap the type to be associated with a policy with PolicyAccess.
 *
 * @tparam T - The type to associate with a redundancy policy.
 * @tparam Policy - An array type where the policy is stored.
 */
template <typename T, typename Policy>
class PolicyAccess : public T
{
  public:
    PolicyAccess() = default;
    PolicyAccess(const PolicyAccess&) = default;
    PolicyAccess& operator=(const PolicyAccess&) = default;
    PolicyAccess(PolicyAccess&&) = default;
    PolicyAccess& operator=(PolicyAccess&&) = default;
    ~PolicyAccess() = default;

    /**
     * @brief Construct a new PolicyAccess wrapped object.
     *
     * @param[in] index - The array index in Policy.
     * @tparam Args - Forwarded to wrapped type constructor.
     */
    template <typename... Args>
    PolicyAccess(size_t index, Args&&... args) :
        T(std::forward<Args>(args)...), policy(index)
    {}

  private:
    /**
     * @brief Get the associated policy.
     */
    RedundancyPolicy& getPolicy() override
    {
        return *Policy::get()[policy];
    }

    /** The associated policy index. */
    size_t policy;
};
} // namespace presence
} // namespace fan
} // namespace phosphor
