This commit is contained in:
flowerstonezl
2026-03-10 17:56:36 +08:00
commit 993581b2a4
22 changed files with 378 additions and 0 deletions

47
src/core/CoreService.cpp Normal file
View File

@@ -0,0 +1,47 @@
#include "CoreService.h"
#include "../utils/logs/logging.h"
CoreService* CoreService::instance()
{
static CoreService inst;
return &inst;
}
CoreService::CoreService(QObject* parent)
: QObject(parent)
, m_initialized(false)
{
}
CoreService::~CoreService()
{
shutdown();
}
bool CoreService::initialize()
{
if (m_initialized) {
LOG_WARNING() << "CoreService already initialized";
return true;
}
LOG_INFO() << "CoreService initializing";
m_initialized = true;
return true;
}
void CoreService::shutdown()
{
if (!m_initialized) {
LOG_DEBUG() << "CoreService shutdown called while not initialized";
return;
}
LOG_INFO() << "CoreService shutting down";
m_initialized = false;
}
bool CoreService::isInitialized() const
{
return m_initialized;
}

23
src/core/CoreService.h Normal file
View File

@@ -0,0 +1,23 @@
#pragma once
#include <QObject>
class CoreService : public QObject {
Q_OBJECT
public:
static CoreService* instance();
bool initialize();
void shutdown();
bool isInitialized() const;
private:
explicit CoreService(QObject* parent = nullptr);
~CoreService();
CoreService(const CoreService&) = delete;
CoreService& operator=(const CoreService&) = delete;
bool m_initialized = false;
};

View File

@@ -0,0 +1,7 @@
#pragma once
// Placeholder for a lock-free ring queue.
class LockFreeQueue {
public:
LockFreeQueue() = default;
};

View File

@@ -0,0 +1,7 @@
#pragma once
// Placeholder for a preallocated memory pool.
class MemoryPool {
public:
MemoryPool() = default;
};

View File

@@ -0,0 +1,5 @@
#pragma once
// Placeholder for data trace model.
struct DataTrace {
};

View File

@@ -0,0 +1,5 @@
#pragma once
// Placeholder for metadata model.
struct Metadata {
};

View File

@@ -0,0 +1,7 @@
#pragma once
// Placeholder protocol plugin interface.
class IProtocolPlugin {
public:
virtual ~IProtocolPlugin() = default;
};

View File

@@ -0,0 +1,7 @@
#pragma once
// Placeholder for plugin manager.
class PluginManager {
public:
PluginManager() = default;
};

View File

@@ -0,0 +1,7 @@
#pragma once
// Placeholder for pipeline context.
class PipelineContext {
public:
PipelineContext() = default;
};

View File

@@ -0,0 +1,7 @@
#pragma once
// Placeholder for pipeline engine.
class PipelineEngine {
public:
PipelineEngine() = default;
};

View File

@@ -0,0 +1,7 @@
#pragma once
// Log stream buffer placeholder.
class LogStream {
public:
LogStream() = default;
};

36
src/utils/logs/logging.h Normal file
View File

@@ -0,0 +1,36 @@
#ifndef LOGGING_H
#define LOGGING_H
#include <QDebug>
#include <QLoggingCategory>
#include <QString>
#include <cstring>
/**
* @file logging.h
* @brief 日志宏定义,提供带文件名和函数名的日志输出,并异步存储到数据库
*/
// 获取文件名(不含路径)
#define __FILENAME__ (strrchr(__FILE__, '/') ? strrchr(__FILE__, '/') + 1 : __FILE__)
// 构建来源字符串的辅助宏
#define __LOG_SOURCE__ (QString(__FILENAME__) + "." + QString(__FUNCTION__))
// 日志宏,格式:[文件名.函数名] 消息
#define LOG_DEBUG() \
qDebug() << "[" << "SYSTEM" << "DEBUG" << __LOG_SOURCE__ << "[" << __FILENAME__ << "." << __FUNCTION__ << "]"
#define LOG_ERROR() \
qCritical() << "[" << "SYSTEM" << "ERROR" << __LOG_SOURCE__ << "[" << __FILENAME__ << "." << __FUNCTION__ << "]"
#define LOG_INFO() \
qInfo() << "[" << "SYSTEM" << "INFO" << __LOG_SOURCE__ << "[" << __FILENAME__ << "." << __FUNCTION__ << "]"
#define LOG_WARNING() \
qWarning() << "[" << "SYSTEM" << "WARNING" << __LOG_SOURCE__ << "[" << __FILENAME__ << "." << __FUNCTION__ << "]"
#endif // LOGGING_H