#pragma once

#include <sdbusplus/bus.hpp>
#include <sdbusplus/server/object.hpp>
#include <sdeventplus/clock.hpp>
#include <sdeventplus/event.hpp>
#include <sdeventplus/utility/timer.hpp>
#include <xyz/openbmc_project/Memory/MemoryECC/server.hpp>

namespace phosphor
{
namespace memory
{

template <typename... T>
using ServerObject = typename sdbusplus::server::object_t<T...>;

using EccInterface = sdbusplus::xyz::openbmc_project::Memory::server::MemoryECC;
using EccObject = ServerObject<EccInterface>;
/** @class
 *  @brief Manages ECC
 */
class ECC :
    sdbusplus::server::object_t<
        sdbusplus::xyz::openbmc_project::Memory::server::MemoryECC>
{
  public:
    ECC() = delete;
    ~ECC() = default;
    ECC(const ECC&) = delete;
    ECC& operator=(const ECC&) = delete;
    ECC(ECC&&) = default;
    ECC& operator=(ECC&&) = default;

    /** @brief Constructs
     *
     * @param[in] bus     - Handle to system dbus
     * @param[in] objPath - The Dbus path
     */
    ECC(sdbusplus::bus_t& bus, const std::string& objPath) :
        sdbusplus::server::object_t<
            sdbusplus::xyz::openbmc_project::Memory::server::MemoryECC>(
            bus, objPath.c_str()),
        _bus(bus), _event(sdeventplus::Event::get_default()),
        _timer(_event, std::bind(&ECC::read, this)) {
            // Nothing to do here
        };

    int64_t previousCeCounter = 0;
    int64_t previousUeCounter = 0;
    int64_t maxECCLog = 0;

    void run();
    void controlEDACReport(std::string);

  private:
    /** @brief sdbusplus bus client connection. */
    sdbusplus::bus_t& _bus;
    /** @brief the Event Loop structure */
    sdeventplus::Event _event;
    /** @brief Read Timer */
    sdeventplus::utility::Timer<sdeventplus::ClockId::Monotonic> _timer;
    /** @brief Read sysfs entries */
    void read();

    /** @brief Set up D-Bus object init */
    void init();

    std::string getValue(std::string);

    void writeValue(std::string, std::string);
    // set ce_count to dbus
    int checkCeCount();
    // set ue_count to dbus
    int checkUeCount();
    // set eccErrorCount to dbus
    void checkEccLogFull(int64_t, int64_t);

    void resetCounter();
    // set maxECCLog value
    void getMaxLogValue();

    void addSELLog(std::string, std::string, std::vector<uint8_t>, bool,
                   uint16_t);
};

} // namespace memory
} // namespace phosphor
