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.
AppFlow/FITK_Kernel/FITKAppFramework/FITKProgramDriverFactory.cpp

78 lines
2.5 KiB
C++

#include "FITKProgramDriverFactory.h"
namespace AppFrame
{
//静态变量初始化
FITKProgramDriverFactory* FITKProgramDriverFactory::_instance = nullptr;
QMutex FITKProgramDriverFactory::m_mutex;
QList<int> FITKProgramDriverFactory::getProgramTypes()
{
return _createFuns.uniqueKeys();
}
/**
* @brief
*
*
*
*
* @param driverType
* @return QStringList
*/
QStringList FITKProgramDriverFactory::getProgramDrivers(const int driverType)
{
// 检查驱动类型是否存在于创建函数映射中,如果不存在则返回空列表
if (!_createFuns.contains(driverType)) return QStringList();
// 获取指定驱动类型的驱动器创建函数集合
DRIVERTypeFuns ds = _createFuns.value(driverType);
// 返回指定驱动类型的驱动器名称列表
return ds.keys();
}
/**
*
*
* @param t
* @param driver
* @return nullptr
*/
std::function<FITKAbstractProgramerDriver*()> FITKProgramDriverFactory::getDriverCreateFun(const int t, const QString driver)
{
// 检查驱动类型是否注册如果没有注册则直接返回nullptr。
if (!_createFuns.contains(t)) return nullptr;
// 获取指定驱动类型下的驱动创建函数集合。
DRIVERTypeFuns ds = _createFuns.value(t);
// 检查驱动名称是否在创建函数集合中如果不在则返回nullptr。
if (!ds.contains(driver)) return nullptr;
// 返回指定驱动名称对应的驱动创建函数。
return ds.value(driver);
}
void FITKProgramDriverFactory::initialize()
{
}
void FITKProgramDriverFactory::finalize()
{
_createFuns.clear();
}
FITKProgramDriverFactoryDeleator::~FITKProgramDriverFactoryDeleator()
{
if (FITKProgramDriverFactory::_instance)
delete FITKProgramDriverFactory::_instance;
FITKProgramDriverFactory::_instance = nullptr;
}
static FITKProgramDriverFactoryDeleator _FPDFDELEATOR__;
}