GrabBag/Device/GalaxyDevice/_Inc/GalaxySDKManager.h
2025-12-20 16:18:12 +08:00

71 lines
1.7 KiB
C++
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#ifndef GALAXYSDKMANAGER_H
#define GALAXYSDKMANAGER_H
#include <mutex>
#include <atomic>
// Galaxy SDK 头文件
#ifdef _WIN32
// Windows 平台使用 C++ API
#define _WINSOCKAPI_ // 防止winsock.h被包含避免与winsock2.h冲突
#include "GXIAPIBase.h"
#include "IGXFactory.h"
using namespace GxIAPICPP;
#else
// Linux/ARM 平台使用 C API
#include "GxIAPI.h"
#endif
/**
* @brief GalaxySDKManager 单例类
* 管理大恒Galaxy SDK的全局初始化和反初始化
* 使用引用计数确保SDK在所有设备关闭后才反初始化
*/
class GalaxySDKManager
{
public:
/**
* @brief 获取单例实例
* @return 单例实例引用
*/
static GalaxySDKManager& GetInstance();
/**
* @brief 初始化SDK引用计数+1
* @return 0-成功,其他-失败
*/
int InitSDK();
/**
* @brief 反初始化SDK引用计数-1为0时真正反初始化
* @return 0-成功,其他-失败
*/
int UninitSDK();
/**
* @brief 检查SDK是否已初始化
* @return true-已初始化false-未初始化
*/
bool IsSDKInitialized() const;
/**
* @brief 获取当前引用计数
* @return 引用计数
*/
int GetRefCount() const;
private:
GalaxySDKManager();
~GalaxySDKManager();
// 禁止拷贝和赋值
GalaxySDKManager(const GalaxySDKManager&) = delete;
GalaxySDKManager& operator=(const GalaxySDKManager&) = delete;
std::mutex m_mutex; // 互斥锁
std::atomic<int> m_refCount; // 引用计数
bool m_bSDKInitialized; // SDK是否已初始化
};
#endif // GALAXYSDKMANAGER_H