You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
43 lines
1005 B
C++
43 lines
1005 B
C++
#include "FITKDataFactory.h"
|
|
#include "FITKAbstractDataObject.h"
|
|
#include <QMutexLocker>
|
|
|
|
namespace Core
|
|
{
|
|
//静态变量初始化
|
|
FITKDataFactory* FITKDataFactory::_instance = nullptr;
|
|
QMutex FITKDataFactory::m_mutex;
|
|
|
|
FITKAbstractObject* FITKDataFactory::create(const QString& key)
|
|
{
|
|
// 线程锁
|
|
QMutexLocker locker(&m_mutex);
|
|
//注册的函数
|
|
if (!_itemDataFuns.contains(key)) return nullptr;
|
|
auto f = _itemDataFuns.value(key);
|
|
//执行函数
|
|
if (f == nullptr) return nullptr;
|
|
auto data = f();
|
|
return data;
|
|
}
|
|
|
|
void FITKDataFactory::initialize()
|
|
{
|
|
//初始化,无需操作
|
|
}
|
|
|
|
void FITKDataFactory::finalize()
|
|
{
|
|
|
|
}
|
|
|
|
FITKDataFactoryDeleator::~FITKDataFactoryDeleator()
|
|
{
|
|
if (FITKDataFactory::_instance)
|
|
delete FITKDataFactory::_instance;
|
|
FITKDataFactory::_instance = nullptr;
|
|
}
|
|
static FITKDataFactoryDeleator __DELEATOR__;
|
|
}
|
|
|