123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129 |
- #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;
- }
|