#include "singletonwork.h" QMutex singletonWork::m_Mutex; singletonWork* singletonWork::m_pInstance = nullptr; CLHQLogApi* singletonWork::m_pLHQLogApi = nullptr; lhhttpapi* singletonWork::m_pLhHttpAPI = nullptr; QString singletonWork::sm_ServerID = nullptr; QString singletonWork::sm_ServerDBID = nullptr; QString singletonWork::sm_ServerUrl = nullptr; QString singletonWork::sm_ServerToken = nullptr; singletonWork::singletonWork() { if(m_pLHQLogApi == nullptr) { m_pLHQLogApi = new CLHQLogApi(); #ifdef WIN32 #ifdef QT_NO_DEBUG QString strDllPath ="LHQLog.dll"; #else QString strDllPath = "LHQLogd.dll"; #endif #else QString strDllPath = QDir::current().path()+"/LHQLog.so"; #endif bool isSuccess = m_pLHQLogApi->Load(strDllPath); qDebug() << (isSuccess?"加载成功13:":"缺少文件:") << strDllPath; m_pLHQLogApi->DoInitial("CAS_Dante_Driver"); } if(m_pLhHttpAPI == nullptr) { qDebug() << "Load LHSqlWebInterface.dll begin"; m_pLhHttpAPI = new lhhttpapi(); #ifdef WIN32 #ifdef QT_NO_DEBUG QString strDllPath = "LHSqlWebInterface.dll"; #else QString strDllPath = "LHSqlWebInterfaced.dll"; #endif #else QString strDllPath = QDir::current().path()+"/LHSqlWebInterface.so"; #endif bool isSuccess = m_pLhHttpAPI->Load(strDllPath); qDebug() << (isSuccess?"加载成功12:":"缺少文件:") << strDllPath; } } singletonWork::~singletonWork() { if(m_pLHQLogApi != nullptr) { delete m_pLHQLogApi; m_pLHQLogApi = nullptr; } if(m_pLhHttpAPI != nullptr) { delete m_pLhHttpAPI; m_pLhHttpAPI = nullptr; } if(m_pInstance != nullptr) { delete m_pInstance; m_pInstance = nullptr; } } void singletonWork::SetServerID(QString strserid) { sm_ServerID = strserid; } void singletonWork::SetServerDBID(QString strserdbid) { sm_ServerDBID = strserdbid; } void singletonWork::SetServerUrl(QString strserurl) { sm_ServerUrl = strserurl; } void singletonWork::SetServerToken(QString strsertoken) { sm_ServerToken = strsertoken; } QString singletonWork::GetServerID() { return sm_ServerID; } QString singletonWork::GetServerDBID() { return sm_ServerDBID; } QString singletonWork::GetServerUrl() { return sm_ServerUrl; } QString singletonWork::GetServerToken() { return sm_ServerToken; } CLHQLogApi *singletonWork::LHQLogAPI() { return m_pLHQLogApi; } lhhttpapi *singletonWork::LhHttpAPI() { return m_pLhHttpAPI; } singletonWork *singletonWork::instance() { //单例对象 if (m_pInstance== nullptr) { QMutexLocker mutexLocker(&m_Mutex); if (m_pInstance == nullptr) { m_pInstance = new singletonWork(); } } return m_pInstance; }