Update 更新文档
This commit is contained in:
119
cleaned_source_code/Sqbase/qtradecore.cpp
Normal file
119
cleaned_source_code/Sqbase/qtradecore.cpp
Normal file
@@ -0,0 +1,119 @@
|
||||
#include "qtradecore.h"
|
||||
#include "qeventbus.h"
|
||||
#include "qsubscriptionmanager.h"
|
||||
#include "qbigordermanager.h"
|
||||
#include "qlogmanager.h"
|
||||
#include "qorderprocessor.h"
|
||||
#include <QDebug>
|
||||
#include <QCoreApplication>
|
||||
QTradeCore* QTradeCore::instance()
|
||||
{
|
||||
static QTradeCore* instance = nullptr;
|
||||
static QMutex mutex;
|
||||
if (!instance) {
|
||||
QMutexLocker locker(&mutex);
|
||||
if (!instance) {
|
||||
instance = new QTradeCore();
|
||||
}
|
||||
}
|
||||
return instance;
|
||||
}
|
||||
QTradeCore::QTradeCore(QObject *parent) : QObject(parent)
|
||||
{
|
||||
}
|
||||
QTradeCore::~QTradeCore()
|
||||
{
|
||||
shutdown();
|
||||
}
|
||||
void QTradeCore::initialize()
|
||||
{
|
||||
if (m_initialized) {
|
||||
qWarning() << "QTradeCore: Already initialized";
|
||||
return;
|
||||
}
|
||||
qDebug() << "QTradeCore: Initializing...";
|
||||
try {
|
||||
m_eventBus = QEventBus::instance();
|
||||
m_subscriptionManager = QSubscriptionManager::instance();
|
||||
m_bigOrderManager = QBigOrderManager::instance();
|
||||
m_logManager = QLogManager::Instance();
|
||||
m_orderProcessor = new QOrderProcessor(this);
|
||||
m_initialized = true;
|
||||
qDebug() << "QTradeCore: Initialization completed successfully";
|
||||
emit systemInitialized();
|
||||
} catch (const std::exception& e) {
|
||||
qCritical() << "QTradeCore: Initialization failed:" << e.what();
|
||||
emit errorOccurred(QString("Initialization failed: %1").arg(e.what()));
|
||||
}
|
||||
}
|
||||
void QTradeCore::shutdown()
|
||||
{
|
||||
if (!m_initialized) {
|
||||
return;
|
||||
}
|
||||
qDebug() << "QTradeCore: Shutting down...";
|
||||
if (m_orderProcessor) {
|
||||
delete m_orderProcessor;
|
||||
m_orderProcessor = nullptr;
|
||||
}
|
||||
m_initialized = false;
|
||||
qDebug() << "QTradeCore: Shutdown completed";
|
||||
emit systemShutdown();
|
||||
}
|
||||
QSubscriptionManager* QTradeCore::subscriptionManager()
|
||||
{
|
||||
if (!m_initialized) {
|
||||
qWarning() << "QTradeCore: Not initialized, cannot access subscription manager";
|
||||
return nullptr;
|
||||
}
|
||||
return m_subscriptionManager;
|
||||
}
|
||||
QOrderProcessor* QTradeCore::orderProcessor()
|
||||
{
|
||||
if (!m_initialized) {
|
||||
qWarning() << "QTradeCore: Not initialized, cannot access order processor";
|
||||
return nullptr;
|
||||
}
|
||||
return m_orderProcessor;
|
||||
}
|
||||
QBigOrderManager* QTradeCore::bigOrderManager()
|
||||
{
|
||||
if (!m_initialized) {
|
||||
qWarning() << "QTradeCore: Not initialized, cannot access big order manager";
|
||||
return nullptr;
|
||||
}
|
||||
return m_bigOrderManager;
|
||||
}
|
||||
QLogManager* QTradeCore::logManager()
|
||||
{
|
||||
if (!m_initialized) {
|
||||
qWarning() << "QTradeCore: Not initialized, cannot access log manager";
|
||||
return nullptr;
|
||||
}
|
||||
return m_logManager;
|
||||
}
|
||||
QEventBus* QTradeCore::eventBus()
|
||||
{
|
||||
if (!m_initialized) {
|
||||
qWarning() << "QTradeCore: Not initialized, cannot access event bus";
|
||||
return nullptr;
|
||||
}
|
||||
return m_eventBus;
|
||||
}
|
||||
QString QTradeCore::getSystemStatus() const
|
||||
{
|
||||
QString status;
|
||||
if (m_initialized) {
|
||||
status = "System is running\n";
|
||||
QStringList components;
|
||||
if (m_subscriptionManager) components << "SubscriptionManager";
|
||||
if (m_orderProcessor) components << "OrderProcessor";
|
||||
if (m_bigOrderManager) components << "BigOrderManager";
|
||||
if (m_logManager) components << "LogManager";
|
||||
if (m_eventBus) components << "EventBus";
|
||||
status += QString("Components: %1\n").arg(components.join(", "));
|
||||
} else {
|
||||
status = "System is not initialized";
|
||||
}
|
||||
return status;
|
||||
}
|
||||
Reference in New Issue
Block a user