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/FITKCore/FITKAbstractObject.hpp

168 lines
4.6 KiB
C++

/**
*
* @file FITKAbstractObject.hpp
* @brief
* @author LiBaojun (libaojunqd@foxmail.com)
* @date 2024-02-23
*
*/
#ifndef _FITKABSTRACTOBJ_HPP__
#define _FITKABSTRACTOBJ_HPP__
#include "FITKCoreAPI.h"
#include <QString>
#include <QMetaType>
#include <QVariant>
#include <QList>
namespace Core
{
class FITKAbstractObjectContainerPrivate;
/**
* @brief
* @author LiBaojun (libaojunqd@foxmail.com)
* @date 2024-05-10
*/
class FITKCoreAPI FITKAbstractObjectPrivate
{
friend FITKAbstractObjectContainerPrivate;
public:
/**
* @brief Construct a new FITKAbstractObjectPrivate object
* @author LiBaojun (libaojunqd@foxmail.com)
* @date 2024-05-10
*/
FITKAbstractObjectPrivate() = default;
/**
* @brief Destroy the FITKAbstractObjectPrivate object
* @author LiBaojun (libaojunqd@foxmail.com)
* @date 2024-05-10
*/
virtual ~FITKAbstractObjectPrivate() = 0;
private:
/**
* @brief
* @author LiBaojun (libaojunqd@foxmail.com)
* @date 2024-05-10
*/
QList<FITKAbstractObjectContainerPrivate*> _containers{};
};
/**
* @brief
* @author LiBaojun (libaojunqd@foxmail.com)
* @date 2024-02-23
*/
class /*FITKCoreAPI*/ FITKAbstractObject : public FITKAbstractObjectPrivate
{
public:
/**
* @brief Construct a new FITKAbstractObject object
* @author LiBaojun (libaojunqd@foxmail.com)
* @date 2024-02-23
*/
explicit FITKAbstractObject() = default;
/**
* @brief Destroy the FITKAbstractObject object
* @author LiBaojun (libaojunqd@foxmail.com)
* @date 2024-02-23
*/
FITKCoreAPI virtual ~FITKAbstractObject() = 0 ;
/**
* @brief className
* @param[i] className
* @return true
* @return false
* @author LiBaojun (libaojunqd@foxmail.com)
* @date 2024-03-04
*/
virtual bool isFITKClass(const QString& className) { Q_UNUSED(className); return false; }
/**
* @brief
* @return QString
* @author LiBaojun (libaojunqd@foxmail.com)
* @date 2024-03-04
*/
virtual QString getClassName() { return QString(); }
template< class T>
/**
* @brief this
* @return T*
* @author LiBaojun (libaojunqd@foxmail.com)
* @date 2024-02-23
*/
T* FITKSafedownCast()
{
return dynamic_cast<T*>(this);
}
template< class T>
/**
* @brief
* @param[i] obj
* @return T*
* @author LiBaojun (libaojunqd@foxmail.com)
* @date 2024-02-23
*/
static T* FITKSafedownCast(FITKAbstractObject* obj)
{
return dynamic_cast<T*>(obj);
}
/**
* @brief QVarient
* @return QVariant
* @author LiBaojun (libaojunqd@foxmail.com)
* @date 2024-03-04
*/
QVariant FITKObj2QVarient()
{
return QVariant::fromValue<FITKAbstractObject*>(this);
}
template <class T>
/**
* @brief qvarientT
* @param[i] va qvarient
* @return T*
* @author LiBaojun (libaojunqd@foxmail.com)
* @date 2024-03-04
*/
static T* QVariant2FITKObj(QVariant va)
{
return va.value<T*>();
}
/**
* @brief enable
* @return true
* @return false
* @author LiBaojun (libaojunqd@foxmail.com)
* @date 2024-05-13
*/
bool FITKCoreAPI isEnable();
/**
* @brief enable
* @param[i] en enable
* @author LiBaojun (libaojunqd@foxmail.com)
* @date 2024-05-13
*/
void FITKCoreAPI enable(bool en = true);
private:
/**
* @brief enable
* @author LiBaojun (libaojunqd@foxmail.com)
* @date 2024-05-13
*/
bool _objEnable{ true };
};
}
Q_DECLARE_METATYPE(Core::FITKAbstractObject*)
#endif // _FITKABSTRACTOBJ_HPP__