JFrame(工程初始化——开篇)

目录结构

 

 

 

 include文件夹存放了所有共享库的头文件,我将每个插件的头文件单独放在了include目录下,这样方便给其余的共享库引用!

src文件夹放了各子工程的源文件!

config文件夹存放配置!

bin目录存放编译出的dll/so

 

 JCore的设计

 

 JCore类是JFrame的核心类,JConfig类聚合于JCore,帮助 JCore 读取配置文件!

另外,插件共用的接口类 IPluginInterface,插件信息结构体也存放在 JCore 项目!

 

入口

JEntry 是 JFrame 的入口,是个 MainWindow 的项目,负责获取 JCore 的实例并 startUP!

1 MainWindow::MainWindow(QWidget *parent) :
2     QMainWindow(parent),
3     ui(new Ui::MainWindow)
4 {
5     ui->setupUi(this);
6     m_coreInstance = JCore::getInstance();
7     QString configsPath = QCoreApplication::applicationDirPath() += "/../config/plugins.xml";
8     m_coreInstance->startUP(configsPath);
9 }
 1 #include "jcore.h"
 2 
 3 JCore *JCore::m_instance = nullptr;
 4 
 5 JCore *JCore::getInstance()
 6 {
 7     if(m_instance == nullptr)
 8     {
 9         m_instance = new JCore();
10     }
11     return m_instance;
12 }
13 
14 int JCore::startUP(QString pluginsPath)
15 {
16     if(-1 == m_config.readAllPlugins(pluginsPath))
17     {
18         return -1;
19     }
20     return 0;
21 }
22 
23 JCore::JCore(QObject *parent)
24     :QObject (parent)
25 {
26 
27 }

 

posted @ 2022-04-13 21:29  SSSnail  阅读(205)  评论(0)    收藏  举报