#pragma once
#include <cstdint>
#include <string>

namespace phosphor
{
namespace fan
{
namespace presence
{

/**
 * @class PresenceSensor
 * @brief PresenceSensor interface.
 *
 * Provide concrete implementations of PresenceSensor to realize
 * new presence detection methods.
 *
 * Note that implementations drive the inventory update process via
 * a redundancy policy (rpolicy.hpp) - it is not enough to implement
 * the interfaces below.
 */
class PresenceSensor
{
  public:
    PresenceSensor(const PresenceSensor&) = default;
    PresenceSensor& operator=(const PresenceSensor&) = default;
    PresenceSensor(PresenceSensor&&) = default;
    PresenceSensor& operator=(PresenceSensor&&) = default;
    virtual ~PresenceSensor() = default;
    PresenceSensor() : id(nextId)
    {
        nextId++;
    }

    /**
     * @brief start
     *
     * Implementations should peform any preparation
     * for detecting presence.  Typical implementations
     * might register signal callbacks or start
     * a polling loop.
     *
     * @return The state of the sensor.
     */
    virtual bool start() = 0;

    /**
     * @brief stop
     *
     * Implementations should stop issuing presence
     * state change notifications.  Typical implementations
     * might de-register signal callbacks or terminate
     * polling loops.
     */
    virtual void stop() = 0;

    /**
     * @brief Check the sensor.
     *
     * Implementations should perform an offline (the start
     * method has not been invoked) query of the presence
     * state.
     *
     * @return The state of the sensor.
     */
    virtual bool present() = 0;

    /**
     * @brief Mark the sensor as failed.
     *
     * Implementations should log an an event if the
     * system policy requires it.
     *
     * Provide a default noop implementation.
     */
    virtual void fail()
    {}

    friend bool operator==(const PresenceSensor& l, const PresenceSensor& r);

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

  private:
    /** @brief Unique sensor ID. */
    std::size_t id;

    /** @brief The next unique sensor ID. */
    static std::size_t nextId;
};

inline bool operator==(const PresenceSensor& l, const PresenceSensor& r)
{
    return l.id == r.id;
}

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