#ifndef TACTILEIPC3D_SERIAL_MANAGER_H
#define TACTILEIPC3D_SERIAL_MANAGER_H

#include <QHash>
#include <QString>
#include <QStringList>
#include <QPluginLoader>
#include <vector>
#include <memory>

#include "protocol_bundle.h"

class SerialManager {
public:
    void registerProtocol(const QString& name, const ProtocolBundle& bundle);
    bool setActiveProtocol(const QString& name);
    QStringList loadPlugins(const QString& dirPath, QStringList* errors = nullptr);

    QString activeProtocol() const { return m_activeName; }
    ProtocolBundle activeBundle() const;

private:
    QHash<QString, ProtocolBundle> m_protocols;
    QString m_activeName;
    std::vector<std::unique_ptr<QPluginLoader>> m_pluginLoaders;
};

#endif // TACTILEIPC3D_SERIAL_MANAGER_H
