#pragma once
#include <spdlog/spdlog.h>
#include <type_traits>
#include "../../core/dispacther.hpp"
#include "./interface.hpp"

namespace lsp::provider
{
    // 注册请求处理器的模板函数
    template<typename ProviderClass>
    typename std::enable_if_t<std::is_base_of_v<IRequestProvider, ProviderClass>>
    RegisterProvider(core::RequestDispatcher& dispatcher)
    {
        auto provider = std::make_shared<ProviderClass>();
        dispatcher.RegisterRequestProvider(provider);
        spdlog::info("Registered request provider [{}] for method: [{}]", provider->GetProviderName(), provider->GetMethod());
    }

    // 注册通知处理器的模板函数
    template<typename ProviderClass>
    typename std::enable_if_t<std::is_base_of_v<INotificationProvider, ProviderClass>>
    RegisterProvider(core::RequestDispatcher& dispatcher)
    {
        auto provider = std::make_shared<ProviderClass>();
        dispatcher.RegisterNotificationProvider(provider);
        spdlog::info("Registered notification provider [{}] for method: [{}]", provider->GetProviderName(), provider->GetMethod());
    }

}
