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.

85 lines
2.5 KiB
C

/**
*
* @file FITKCoreMacros.h
* @brief
* @author LiBaojun (libaojunqd@foxmail.com)
* @date 2024-02-22
*
*/
#ifndef __FITKCIREMACROS_H__
#define __FITKCIREMACROS_H__
/**
* @brief
* @author LiBaojun (libaojunqd@foxmail.com)
* @date 2023-03-28
*/
#define ForwardDeclar( aClass ) class aClass;
/**
* @brief
* @author LiBaojun (libaojunqd@foxmail.com)
* @date 2023-03-28
*/
#define ForwardDeclarNS( aNamespace, aClass ) \
namespace aNamespace \
{ \
class aClass; \
}
/**
* @brief
* @author LiBaojun (libaojunqd@foxmail.com)
* @date 2023-03-28
*/
#define FITKSafeDownCastA( thisClass, superClass ) \
public: \
static thisClass* SafeDownCast##thisClass##( superClass * obj ) \
{ \
return dynamic_cast< thisClass* >( obj ); \
}
/**
* @brief
* @author LiBaojun (libaojunqd@foxmail.com)
* @date 2023-03-28
*/
#define DeclSingleton( thisClass ) \
private: \
static thisClass* _instance; \
static QMutex m_mutex; \
thisClass( ) { this->initialize( ); } \
~thisClass( ) {this->finalize(); } \
\
public: \
static thisClass* getInstance( ) \
{ \
QMutexLocker l(&m_mutex); \
if ( _instance == nullptr ) \
_instance = new thisClass; \
return _instance; \
}
/**
* @brief
* @author LiBaojun (libaojunqd@foxmail.com)
* @date 2024-03-07
*/
#define FITKCLASS(NS,thisClass) \
public: \
virtual bool isFITKClass(const QString& className) override \
{ \
return className == #thisClass; \
} \
virtual QString getClassName() override \
{ \
QString sNamespace(#NS); \
QString className(#thisClass); \
if(sNamespace.isEmpty()) \
return #thisClass; \
return sNamespace+"::"+className; \
}
#endif