ZFFramework
Loading...
Searching...
No Matches
ZFCoreStaticRegister.h
Go to the documentation of this file.
1
5#ifndef _ZFI_ZFCoreStaticRegister_h_
6#define _ZFI_ZFCoreStaticRegister_h_
7
8#include "ZFCoreTypeDef.h"
9
10// #define _ZFP_ZFCoreStaticRegister_DEBUG 1
11
12#if _ZFP_ZFCoreStaticRegister_DEBUG
14 #define _ZFP_ZFCoreStaticRegister_invokeTimeLogger(fmt, ...) \
15 zfimplInvokeTimeLogger("[ZFSR] " fmt \
16 , ##__VA_ARGS__ \
17 )
18#else
19 #define _ZFP_ZFCoreStaticRegister_invokeTimeLogger(fmt, ...)
20#endif
21
23
24// ============================================================
43#define ZF_STATIC_REGISTER_INIT(Name) \
44 ZFLIB_HIDDEN_BEGIN() \
45 \
46 zfclassNotPOD _ZFP_R_##Name { \
47 protected: \
48 typedef _ZFP_R_##Name zfself; \
49 public: \
50 _ZFP_R_##Name(void)
51
52#define ZF_STATIC_REGISTER_DESTROY(Name) \
53 ~_ZFP_R_##Name(void)
54
55#define ZF_STATIC_REGISTER_END(Name) \
56 }; \
57 static _ZFP_R_##Name _ZFP_RI_##Name; \
58 \
59 ZFLIB_HIDDEN_END()
60
61#define ZF_STATIC_REGISTER_INSTANCE(Name) \
62 (&_ZFP_RI_##Name)
63
64#if _ZFP_ZFCoreStaticRegister_DEBUG
65 #undef ZF_STATIC_REGISTER_INIT
66 #undef ZF_STATIC_REGISTER_DESTROY
67 #undef ZF_STATIC_REGISTER_END
68
69 #define ZF_STATIC_REGISTER_INIT(Name) \
70 ZFLIB_HIDDEN_BEGIN() \
71 \
72 zfclassNotPOD _ZFP_R_##Name { \
73 protected: \
74 typedef _ZFP_R_##Name zfself; \
75 public: \
76 _ZFP_R_##Name(void) { \
77 _ZFP_ZFCoreStaticRegister_invokeTimeLogger("reg: %s", #Name); \
78 _ZFP_R_Reg(); \
79 } \
80 void _ZFP_R_Reg(void)
81 #define ZF_STATIC_REGISTER_DESTROY(Name) \
82 ~_ZFP_R_##Name(void) { \
83 _ZFP_ZFCoreStaticRegister_invokeTimeLogger("unreg: %s", #Name); \
84 _ZFP_R_Unreg(); \
85 } \
86 void _ZFP_R_Unreg(void)
87 #define ZF_STATIC_REGISTER_END(Name) \
88 }; \
89 static _ZFP_R_##Name _ZFP_RI_##Name; \
90 \
91 ZFLIB_HIDDEN_END()
92#endif
93
95#endif // #ifndef _ZFI_ZFCoreStaticRegister_h_
96
types for ZFFramework
#define ZF_NAMESPACE_GLOBAL_BEGIN
begin namespace ZFFramework
Definition ZFNamespace.h:97
#define ZF_NAMESPACE_GLOBAL_END
end namespace ZFFramework
Definition ZFNamespace.h:98
minimal log util for internal debug use only