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.

87 lines
2.2 KiB
C++

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

/**
*
* @file FITKAbstractFactory.h
* @brief 抽象工厂类
* @author LiBaojun (libaojunqd@foxmail.com)
* @date 2024-03-02
*
*/
#ifndef __FITKABSTRACTFACTORY_H__
#define __FITKABSTRACTFACTORY_H__
#include "FITKAbstractObject.hpp"
#include <QString>
namespace Core
{
/**
* @brief 抽象工工厂声明
* @author LiBaojun (libaojunqd@foxmail.com)
* @date 2024-03-02
*/
class FITKCoreAPI FITKAbstractFactory : public FITKAbstractObject
{
public:
/**
* @brief Construct a new FITKAbstractFactory object
* @author LiBaojun (libaojunqd@foxmail.com)
* @date 2024-03-02
*/
explicit FITKAbstractFactory() = default;
/**
* @brief Destroy the FITKAbstractFactory object
* @author LiBaojun (libaojunqd@foxmail.com)
* @date 2024-03-02
*/
virtual ~FITKAbstractFactory() = 0;
/**
* @brief 根据key创建对象
* @param[i] key 关键字
* @return FITKAbstractObject*
* @author LiBaojun (libaojunqd@foxmail.com)
* @date 2024-03-02
*/
virtual FITKAbstractObject* create(const QString& key );
/**
* @brief 根据key创建对象
* @param[i] key 关键字
* @return FITKAbstractObject*
* @author LiBaojun (libaojunqd@foxmail.com)
* @date 2024-03-02
*/
virtual FITKAbstractObject* create(const int key) ;
template<class T>
/**
* @brief 根据key创建对象并转换类型
* @param[i] key 关键字
* @return FITKAbstractObject*
* @author LiBaojun (libaojunqd@foxmail.com)
* @date 2024-03-02
*/
T* createT(const QString & key)
{
return dynamic_cast<T*>(create(key));
}
template<class T>
/**
* @brief 根据key创建对象并转换类型
* @param[i] key 关键字
* @return FITKAbstractObject*
* @author LiBaojun (libaojunqd@foxmail.com)
* @date 2024-03-02
*/
T* createT(const int key)
{
return dynamic_cast<T*>(create(key));
}
};
}
#endif