#pragma once

#include <QObject>
#include <QPluginLoader>
#include "interfaces/plugin_interface.hpp"

class PluginLoader : public QObject
{
    Q_OBJECT

public:
    explicit PluginLoader(QObject *parent = nullptr);

    Q_INVOKABLE QObject *loadPlugin(const QString &path);
    Q_INVOKABLE bool unloadPlugin();
    Q_INVOKABLE QString errorString() const;

signals:
    void messagePublished(const QString &message, int index);
    void error(const QString &errorString);

private:
    QPluginLoader m_loader;
};
