#include "core/plugin_system/PluginManager.h"

namespace softbus::core::plugin_system
{

void PluginManager::registerProtocolPlugin(std::shared_ptr<IProtocolPlugin> plugin)
{
    if (!plugin) {
        return;
    }
    m_protocolPlugins.insert(plugin->pluginId(), std::move(plugin));
}

std::shared_ptr<IProtocolPlugin> PluginManager::selectProtocolPlugin(const QString& protocolHint) const
{
    for (auto it = m_protocolPlugins.constBegin(); it != m_protocolPlugins.constEnd(); ++it) {
        if (it.value() && it.value()->supports(protocolHint)) {
            return it.value();
        }
    }
    return {};
}

} // namespace softbus::core::plugin_system
