add library register
This commit is contained in:
parent
3b8d76258d
commit
eeebb5bfc9
13
doric-Qt/example/doric/Doric.h
Normal file
13
doric-Qt/example/doric/Doric.h
Normal file
@ -0,0 +1,13 @@
|
||||
#ifndef DORIC_H
|
||||
#define DORIC_H
|
||||
|
||||
#include "DoricLibrary.h"
|
||||
|
||||
class Doric {
|
||||
public:
|
||||
static void registerLibrary(DoricLibrary *doricLibrary) {
|
||||
DoricRegistry::getInstance()->registerLibrary(doricLibrary);
|
||||
}
|
||||
};
|
||||
|
||||
#endif // DORIC_H
|
11
doric-Qt/example/doric/DoricLibrary.h
Normal file
11
doric-Qt/example/doric/DoricLibrary.h
Normal file
@ -0,0 +1,11 @@
|
||||
#ifndef DORICLIBRARY_H
|
||||
#define DORICLIBRARY_H
|
||||
|
||||
#include "DoricRegistry.h"
|
||||
|
||||
class DoricLibrary {
|
||||
public:
|
||||
virtual void load(DoricRegistry *registry) = 0;
|
||||
};
|
||||
|
||||
#endif // DORICLIBRARY_H
|
@ -1,4 +1,5 @@
|
||||
#include "DoricRegistry.h"
|
||||
#include "DoricLibrary.h"
|
||||
|
||||
#include "plugin/DoricModalPlugin.h"
|
||||
#include "plugin/DoricNetworkPlugin.h"
|
||||
@ -41,3 +42,8 @@ bool DoricRegistry::acquirePluginInfo(QString name) {
|
||||
bool DoricRegistry::acquireNodeInfo(QString name) {
|
||||
return nodes.acquireClass(name);
|
||||
}
|
||||
|
||||
void DoricRegistry::registerLibrary(DoricLibrary *doricLibrary) {
|
||||
doricLibraries.insert(doricLibrary);
|
||||
doricLibrary->load(this);
|
||||
}
|
||||
|
@ -1,12 +1,27 @@
|
||||
#ifndef REGISTRY_H
|
||||
#define REGISTRY_H
|
||||
|
||||
#include <QDebug>
|
||||
#include <QString>
|
||||
|
||||
#include "utils/DoricObjectFactory.h"
|
||||
|
||||
class DoricLibrary;
|
||||
|
||||
class DoricRegistry {
|
||||
private:
|
||||
static DoricRegistry *local_instance;
|
||||
|
||||
~DoricRegistry() { qDebug() << "destructor"; }
|
||||
|
||||
public:
|
||||
static DoricRegistry *getInstance() {
|
||||
static DoricRegistry instance;
|
||||
return &instance;
|
||||
}
|
||||
|
||||
QSet<DoricLibrary *> doricLibraries;
|
||||
|
||||
DoricObjectFactory plugins;
|
||||
DoricObjectFactory nodes;
|
||||
|
||||
@ -23,6 +38,8 @@ public:
|
||||
bool acquirePluginInfo(QString name);
|
||||
|
||||
bool acquireNodeInfo(QString name);
|
||||
|
||||
void registerLibrary(DoricLibrary *doricLibrary);
|
||||
};
|
||||
|
||||
#endif // REGISTRY_H
|
||||
|
@ -89,9 +89,11 @@ else: unix:!android: target.path = /opt/$${TARGET}/bin
|
||||
!isEmpty(target.path): INSTALLS += target
|
||||
|
||||
HEADERS += \
|
||||
Doric.h \
|
||||
DoricContext.h \
|
||||
DoricContextManager.h \
|
||||
DoricInterfaceDriver.h \
|
||||
DoricLibrary.h \
|
||||
DoricNativeDriver.h \
|
||||
DoricPanel.h \
|
||||
DoricRegistry.h \
|
||||
|
@ -11,7 +11,7 @@ class DoricJSEngine : public QObject {
|
||||
Q_OBJECT
|
||||
private:
|
||||
DoricInterfaceJSE *mJSE;
|
||||
DoricRegistry *mRegistry = new DoricRegistry();
|
||||
DoricRegistry *mRegistry = DoricRegistry::getInstance();
|
||||
|
||||
void loadBuiltinJS(QString assetName);
|
||||
QString packageContextScript(QString contextId, QString content);
|
||||
|
Reference in New Issue
Block a user