#pragma once

#include <QObject>
#include <QPluginLoader>
#include <QVariant>
#include "qtpluginsmanagerprivate.h"
#include "pluginMetaData.h"
#include <QDir>

class  QtPluginsManager : public QObject
{
    Q_OBJECT

public:
    static QtPluginsManager &getInstance()
    {
        static QtPluginsManager m_instance;
        return m_instance;
    }
public:
    QDir getPluginPath();
    //в
    void loadAllPlugins();
    //ɨJSONļеĲԪ
    void scan(const QString &filepath);
    //ĳ
    void loadPlugin(const QString &filepath);
    //жв
    void unloadAllPlugins();
    //жĳ
    void unloadPlugin(const QString &filepath);
    //ȡв
    QList<QPluginLoader *> allPlugins();
    //ȡĳ(by name)
    QPluginLoader* getPlugin(const QString &name);
    //ȡĳ(by type)
    QList<QPluginLoader *> getPluginsByType(const QVariant&);
    //ʼͲͨŵźŲ
    void initSignalAndSlot();

    //Ϊвvar
    void bindVarForAllPlugins(QMap<int, QVector<QString>>&);

public slots:
    //ԸϢ
    void recMsgfromPlugin(PluginMetaData);
private:
    QtPluginsManager()
    {
     d = new QtPluginsManagerPrivate;
    };
    QtPluginsManagerPrivate *d;
};

