#pragma once

#include "status.hpp"

#include <sdbusplus/bus.hpp>
#include <sdbusplus/bus/match.hpp>

#include <memory>
#include <string>

namespace ipmi_flash
{

class SystemdNoFile : public TriggerableActionInterface
{
  public:
    static std::unique_ptr<TriggerableActionInterface>
        CreateSystemdNoFile(sdbusplus::bus_t&& bus, const std::string& service,
                            const std::string& mode);

    SystemdNoFile(sdbusplus::bus_t&& bus, const std::string& service,
                  const std::string& mode) :
        bus(std::move(bus)), triggerService(service), mode(mode)
    {}

    SystemdNoFile(const SystemdNoFile&) = delete;
    SystemdNoFile& operator=(const SystemdNoFile&) = delete;
    // sdbusplus match requires us to be pinned
    SystemdNoFile(SystemdNoFile&&) = delete;
    SystemdNoFile& operator=(SystemdNoFile&&) = delete;

    bool trigger() override;
    void abort() override;
    ActionStatus status() override;

    const std::string& getMode() const;

  private:
    sdbusplus::bus_t bus;
    const std::string triggerService;
    const std::string mode;

    std::optional<sdbusplus::bus::match_t> jobMonitor;
    std::optional<std::string> job;
    ActionStatus currentStatus = ActionStatus::unknown;

    void match(sdbusplus::message_t& m);
};

/**
 * Representation of what is used for triggering an action with systemd and
 * checking the result by reading a file.
 */
class SystemdWithStatusFile : public SystemdNoFile
{
  public:
    /**
     * Create a default SystemdWithStatusFile object that uses systemd to
     * trigger the process.
     *
     * @param[in] bus - an sdbusplus handler for a bus to use.
     * @param[in] path - the path to check for verification status.
     * @param[in] service - the systemd service to start to trigger
     * verification.
     * @param[in] mode - the job-mode when starting the systemd Unit.
     */
    static std::unique_ptr<TriggerableActionInterface>
        CreateSystemdWithStatusFile(
            sdbusplus::bus_t&& bus, const std::string& path,
            const std::string& service, const std::string& mode);

    SystemdWithStatusFile(sdbusplus::bus_t&& bus, const std::string& path,
                          const std::string& service, const std::string& mode) :
        SystemdNoFile(std::move(bus), service, mode), checkPath(path)
    {}

    bool trigger() override;
    ActionStatus status() override;

  private:
    const std::string checkPath;
};

} // namespace ipmi_flash
