This repository has been archived on 2024-07-22. You can view files and clone it, but cannot push or open issues or pull requests.
Doric/doric-Qt/example/doric/DoricRegistry.h

48 lines
892 B
C
Raw Normal View History

2021-02-04 16:59:58 +08:00
#ifndef REGISTRY_H
#define REGISTRY_H
2021-05-17 16:18:44 +08:00
#include <QDebug>
2021-02-04 16:59:58 +08:00
#include <QString>
2021-05-18 16:15:28 +08:00
#include "DoricExport.h"
2021-02-04 16:59:58 +08:00
#include "utils/DoricObjectFactory.h"
2021-05-17 16:18:44 +08:00
class DoricLibrary;
2021-05-18 16:15:28 +08:00
class DORIC_EXPORT DoricRegistry {
2021-05-17 16:18:44 +08:00
private:
static DoricRegistry *local_instance;
~DoricRegistry() { qDebug() << "destructor"; }
2021-02-04 16:59:58 +08:00
public:
2021-05-17 16:18:44 +08:00
static DoricRegistry *getInstance() {
static DoricRegistry instance;
return &instance;
}
QSet<DoricLibrary *> doricLibraries;
2021-02-20 16:20:18 +08:00
DoricObjectFactory plugins;
DoricObjectFactory nodes;
2021-02-04 16:59:58 +08:00
DoricRegistry();
template <typename T> void registerNativePlugin(QString name) {
2021-02-20 16:20:18 +08:00
plugins.registerClass<T>(name);
}
template <typename T> void registerViewNode(QString name) {
nodes.registerClass<T>(name);
2021-02-04 16:59:58 +08:00
}
bool acquirePluginInfo(QString name);
bool acquireNodeInfo(QString name);
2021-05-17 16:18:44 +08:00
void registerLibrary(DoricLibrary *doricLibrary);
2021-02-04 16:59:58 +08:00
};
#endif // REGISTRY_H