/**
 * Copyright © 2022 IBM Corporation
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
#pragma once

#include "extensions/phal/create_pel.hpp"

#include <fmt/format.h>

#include <sdeventplus/utility/timer.hpp>

#include <chrono>

namespace openpower::phal::clock
{

/* Dbus event timer */
using Timer = sdeventplus::utility::Timer<sdeventplus::ClockId::Monotonic>;

/**
 * @class Manager - Represents the clock daily management functions
 *
 */
class Manager
{
  public:
    Manager() = delete;
    Manager(const Manager&) = delete;
    Manager(Manager&&) = delete;
    Manager& operator=(const Manager&) = delete;
    Manager& operator=(Manager&&) = delete;
    ~Manager() = default;

    /**
     * Constructor
     * Starts the functions required to capture clock daily logger data.
     *
     * @param[in] event - sdeventplus event loop
     */
    Manager(const sdeventplus::Event& event);

    /**
     * @brief Add a dbus timer
     */
    void addTimer();

    /**
     * @brief Callback when a timer expires
     */
    void timerExpired();

    /**
     * @brief utility function to create clock data log
     */
    void createClockDataLog();

    /**
     * @brief Add processor specific CFAM data to daily logger.
     *
     * @param[in] proc - pdbg processor target
     * @param[out] ffdcData - reference to clock data log
     */
    void addCFAMData(struct pdbg_target* proc,
                     openpower::pel::FFDCData& clockDataLog);

  private:
    /* The sdeventplus even loop to use */
    sdeventplus::Event _event;

    /** @brief Timer used for LEDs lamp test period */
    sdeventplus::utility::Timer<sdeventplus::ClockId::Monotonic> timer;
};

} // namespace openpower::phal::clock
