80 lines
1.2 KiB
C++
80 lines
1.2 KiB
C++
#include "MvsSDKManager.h"
|
|
#include "MvCameraControl.h"
|
|
#include "VrError.h"
|
|
|
|
MvsSDKManager::MvsSDKManager()
|
|
: m_refCount(0)
|
|
, m_bSDKInitialized(false)
|
|
{
|
|
}
|
|
|
|
MvsSDKManager::~MvsSDKManager()
|
|
{
|
|
if (m_bSDKInitialized)
|
|
{
|
|
MV_CC_Finalize();
|
|
m_bSDKInitialized = false;
|
|
}
|
|
}
|
|
|
|
MvsSDKManager& MvsSDKManager::GetInstance()
|
|
{
|
|
static MvsSDKManager instance;
|
|
return instance;
|
|
}
|
|
|
|
int MvsSDKManager::InitSDK()
|
|
{
|
|
std::lock_guard<std::mutex> lock(m_mutex);
|
|
|
|
m_refCount++;
|
|
|
|
if (m_bSDKInitialized)
|
|
{
|
|
return SUCCESS;
|
|
}
|
|
|
|
int ret = MV_CC_Initialize();
|
|
if (ret == MV_OK)
|
|
{
|
|
m_bSDKInitialized = true;
|
|
return SUCCESS;
|
|
}
|
|
|
|
m_refCount--;
|
|
return ret;
|
|
}
|
|
|
|
int MvsSDKManager::UninitSDK()
|
|
{
|
|
std::lock_guard<std::mutex> lock(m_mutex);
|
|
|
|
if (m_refCount > 0)
|
|
{
|
|
m_refCount--;
|
|
}
|
|
|
|
if (m_refCount == 0 && m_bSDKInitialized)
|
|
{
|
|
int ret = MV_CC_Finalize();
|
|
if (ret == MV_OK)
|
|
{
|
|
m_bSDKInitialized = false;
|
|
return SUCCESS;
|
|
}
|
|
return ret;
|
|
}
|
|
|
|
return SUCCESS;
|
|
}
|
|
|
|
bool MvsSDKManager::IsSDKInitialized() const
|
|
{
|
|
return m_bSDKInitialized;
|
|
}
|
|
|
|
int MvsSDKManager::GetRefCount() const
|
|
{
|
|
return m_refCount.load();
|
|
}
|