45 lines
2.0 KiB
C
45 lines
2.0 KiB
C
|
#pragma once
|
||
|
|
||
|
#include "XNCore_global.h"
|
||
|
|
||
|
namespace XNSim {
|
||
|
// 空类宏
|
||
|
struct XNNullClass {};
|
||
|
} // namespace XNSim
|
||
|
|
||
|
// 禁止拷贝构造和赋值宏
|
||
|
#define XN_NOCOPYABLE(Class) \
|
||
|
public: \
|
||
|
using NoCopyable = Class; \
|
||
|
\
|
||
|
private: \
|
||
|
Class(const Class &) = delete; \
|
||
|
Class &operator=(const Class &) = delete;
|
||
|
|
||
|
// 声明私有类宏
|
||
|
#define XN_DECLARE_PRIVATE(Class) \
|
||
|
XN_NOCOPYABLE(Class) \
|
||
|
protected: \
|
||
|
friend class Class##Private; \
|
||
|
inline Class##Private *GetPP() const { \
|
||
|
return reinterpret_cast<Class##Private *>(_Private_Ptr); \
|
||
|
} \
|
||
|
using PrivateType = Class##Private;
|
||
|
|
||
|
// 获取私有类指针宏
|
||
|
#define T_D() PrivateType *const d = GetPP()
|
||
|
|
||
|
// 元类型声明宏
|
||
|
#define XN_METATYPE_P(cls) \
|
||
|
public: \
|
||
|
using ThisType = cls; \
|
||
|
using SuperType = XNSim::XNNullClass;
|
||
|
|
||
|
// 元类型声明宏
|
||
|
#define XN_METATYPE(cls, sup) \
|
||
|
public: \
|
||
|
using ThisType = cls; \
|
||
|
using SuperType = sup;
|
||
|
|
||
|
// 忽略参数宏
|
||
|
#define XN_UNUSED(x) (void)x
|