#include "serial_manager.h"

void SerialManager::registerProtocol(const QString& name, const ProtocolBundle& bundle) {
    if (name.isEmpty())
        return;
    m_protocols.insert(name, bundle);
    if (m_activeName.isEmpty())
        m_activeName = name;
}

bool SerialManager::setActiveProtocol(const QString& name) {
    if (!m_protocols.contains(name))
        return false;
    m_activeName = name;
    return true;
}

SerialManager::ProtocolBundle SerialManager::activeBundle() const {
    if (!m_protocols.contains(m_activeName))
        return {};
    return m_protocols.value(m_activeName);
}
