/*
 * Copyright © 2025 Volla Systeme GmbH.
 *
 * This program is free software: you can redistribute it and/or modify it
 * under the terms of the GNU General Public License version 3,
 * as published by the Free Software Foundation.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

#pragma once

#include "src/core/handler_registration.h"

#include "high_brightness_mode.h"
#include "path.h"
#include "event_loop.h"

#include <memory>
#include <string>

namespace repowerd
{

class Filesystem;
class Path;
class Log;

class SysfsHBM : public HighBrightnessMode
{
public:
    SysfsHBM(
        std::shared_ptr<Log> const& log,
        std::shared_ptr<Filesystem> const& filesystem);

    void set_enabled(bool enabled) override;
    bool get_enabled() override;
    bool is_supported() const override;

    HandlerRegistration register_high_brightness_mode_handler(
        HighBrightnessModeHandler const& handler) override;

private:
    std::shared_ptr<Log> const log;
    std::shared_ptr<Filesystem> const filesystem;
    Path sysfs_hbm_file;
    std::string const hbm_enabled_value;
    std::string const hbm_disabled_value;

    EventLoop event_loop;
    HighBrightnessModeHandler hbm_handler;
    std::mutex handlers_mutex;
};

}
