/* -*- Mode: C++; indent-tabs-mode: nil; tab-width: 4 -*-
 * -*- coding: utf-8 -*-
 *
 * Copyright (C) 2025 KylinSoft Co., Ltd.
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published
 * the Free Software Foundation, either version 3 of the License, or
 * any later version.
 *
 * 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/>.
 */

#ifndef AUDIOCONTEXT_H
#define AUDIOCONTEXT_H

#include "simple_logger/Logger.h"
#include "BaseType.h"
#include "Util.h"

namespace UkuiAudioFramwork
{
#define AUDIO_DEBUG(fmt, ...) DBG_DEBUG(AudioContext::getInstance().getLogger(), EnumToInt(AudioContext::getInstance().getModule()), fmt, ##__VA_ARGS__)
#define AUDIO_INFO(fmt, ...) DBG_INFO(AudioContext::getInstance().getLogger(), EnumToInt(AudioContext::getInstance().getModule()), fmt, ##__VA_ARGS__)
#define AUDIO_WARN(fmt, ...) DBG_WARN(AudioContext::getInstance().getLogger(), EnumToInt(AudioContext::getInstance().getModule()), fmt, ##__VA_ARGS__)
#define AUDIO_ERROR(fmt, ...) DBG_ERROR(AudioContext::getInstance().getLogger(), EnumToInt(AudioContext::getInstance().getModule()), fmt, ##__VA_ARGS__)
#define AUDIO_FATAL(fmt, ...) DBG_FATAL(AudioContext::getInstance().getLogger(), EnumToInt(AudioContext::getInstance().getModule()), fmt, ##__VA_ARGS__)

class AudioContext
{
public:
    static AudioContext& getInstance();

public:
    Module getModule() const;
    simple_logger::Log& getLogger();

private:
    std::string getLogPath();

private:
    AudioContext();
    AudioContext(const AudioContext&) = delete;
    AudioContext(AudioContext&&) = delete;
    AudioContext operator=(const AudioContext&) = delete;
    AudioContext operator=(AudioContext&&) = delete;
    virtual ~AudioContext() {
        m_log.Close();
    }

private:
    simple_logger::Log m_log;
    Module m_module = Module::Service;
};
}


#endif // AUDIOCONTEXT_H
