6#ifndef _ZFI_ZFCoreUtilAutoPtr_h_
7#define _ZFI_ZFCoreUtilAutoPtr_h_
15template<
typename T_POD>
18 explicit _ZFP_zflineFreeContainer(
ZF_IN T_POD *p) : p(p) {}
19 ~_ZFP_zflineFreeContainer(
void) {
25template<
typename T_POD>
26_ZFP_zflineFreeContainer<T_POD> _ZFP_zflineFreeWrapper(
ZF_IN T_POD *p) {
27 return _ZFP_zflineFreeContainer<T_POD>(p);
32#define zflineFree(obj) (_ZFP_zflineFreeWrapper(obj).p)
38 _ZFP_zfblockedFreeContainer(
ZF_IN void *p) : p(p) {}
39 ~_ZFP_zfblockedFreeContainer(
void) {
57#define zfblockedFree(obj) \
58 _ZFP_zfblockedFreeContainer ZFUniqueName(zfblockedFree_)(obj)
62template<
typename T_Object>
65 _ZFP_zflineDeleteContainer(
ZF_IN const _ZFP_zflineDeleteContainer &ref) : p(ref.p) {}
66 _ZFP_zflineDeleteContainer(
ZF_IN T_Object *p) : p(p) {}
67 ~_ZFP_zflineDeleteContainer(
void) {
73template<
typename T_Object>
74_ZFP_zflineDeleteContainer<T_Object> _ZFP_zflineDeleteWrapper(
ZF_IN T_Object *p) {
75 return _ZFP_zflineDeleteContainer<T_Object>(p);
80#define zflineDelete(obj) (_ZFP_zflineDeleteWrapper(obj).p)
84typedef void (*_ZFP_zfblockedDeleteCallback)(
ZF_IN void *p);
85template<
typename T_Object>
86void _ZFP_zfblockedDeleteOnDelete(
ZF_IN void *p) {
91 _ZFP_zfblockedDeleteContainer(
void) : p(
zfnull), deleteCallback(
zfnull) {}
92 ~_ZFP_zfblockedDeleteContainer(
void) {
94 this->deleteCallback(this->p);
99 _ZFP_zfblockedDeleteCallback deleteCallback;
101template<
typename T_Object>
102void _ZFP_zfblockedDeleteSetup(
103 ZF_IN _ZFP_zfblockedDeleteContainer *container
104 ,
ZF_IN T_Object *
const &p
106 container->p = (
void *)p;
107 container->deleteCallback = _ZFP_zfblockedDeleteOnDelete<T_Object>;
121#define zfblockedDelete(obj) \
122 _ZFP_zfblockedDeleteContainer ZFUniqueName(zfblockedDelete_); \
123 _ZFP_zfblockedDeleteSetup(&ZFUniqueName(zfblockedDelete_), obj)
130#define zfblockedCleanup_1(action \
133 zfclassLikePOD ZFUniqueName(zfblockedCleanup_T) { \
135 ZFUniqueName(zfblockedCleanup_T)(P0 &p0) \
138 ~ZFUniqueName(zfblockedCleanup_T)(void) { \
143 } ZFUniqueName(zfblockedCleanup_)(p0)
145#define zfblockedCleanup_2(action \
149 zfclassLikePOD ZFUniqueName(zfblockedCleanup_T) { \
151 ZFUniqueName(zfblockedCleanup_T)(P0 &p0 \
157 ~ZFUniqueName(zfblockedCleanup_T)(void) { \
163 } ZFUniqueName(zfblockedCleanup_)(p0 \
167#define zfblockedCleanup_3(action \
172 zfclassLikePOD ZFUniqueName(zfblockedCleanup_T) { \
174 ZFUniqueName(zfblockedCleanup_T)(P0 &p0 \
182 ~ZFUniqueName(zfblockedCleanup_T)(void) { \
189 } ZFUniqueName(zfblockedCleanup_)(p0 \
194#define zfblockedCleanup_4(action \
200 zfclassLikePOD ZFUniqueName(zfblockedCleanup_T) { \
202 ZFUniqueName(zfblockedCleanup_T)(P0 &p0 \
212 ~ZFUniqueName(zfblockedCleanup_T)(void) { \
220 } ZFUniqueName(zfblockedCleanup_)(p0 \
226#define zfblockedCleanup_5(action \
233 zfclassLikePOD ZFUniqueName(zfblockedCleanup_T) { \
235 ZFUniqueName(zfblockedCleanup_T)(P0 &p0 \
247 ~ZFUniqueName(zfblockedCleanup_T)(void) { \
256 } ZFUniqueName(zfblockedCleanup_)(p0 \
263#define zfblockedCleanup_6(action \
271 zfclassLikePOD ZFUniqueName(zfblockedCleanup_T) { \
273 ZFUniqueName(zfblockedCleanup_T)(P0 &p0 \
287 ~ZFUniqueName(zfblockedCleanup_T)(void) { \
297 } ZFUniqueName(zfblockedCleanup_)(p0 \
305#define zfblockedCleanup_7(action \
314 zfclassLikePOD ZFUniqueName(zfblockedCleanup_T) { \
316 ZFUniqueName(zfblockedCleanup_T)(P0 &p0 \
332 ~ZFUniqueName(zfblockedCleanup_T)(void) { \
343 } ZFUniqueName(zfblockedCleanup_)(p0 \
352#define zfblockedCleanup_8(action \
362 zfclassLikePOD ZFUniqueName(zfblockedCleanup_T) { \
364 ZFUniqueName(zfblockedCleanup_T)(P0 &p0 \
382 ~ZFUniqueName(zfblockedCleanup_T)(void) { \
394 } ZFUniqueName(zfblockedCleanup_)(p0 \
#define ZFLIB_ZFCore
used to export symbols
Definition ZFCoreEnvDef.h:30
#define zfclassLikePOD
shows the class is not a POD type, but you may use it like a POD except memset it to 0
Definition ZFCoreTypeDef_ClassType.h:41
#define zfdelete(instance)
same as delete defined for future use
Definition ZFCoreTypeDef_ClassType.h:91
#define zffree(ptr)
same as free defined for future use, do nothing if ptr is NULL
Definition ZFCoreTypeDef_ClassType.h:112
#define ZF_IN
dummy macro that shows the param used as required input
Definition ZFCoreTypeDef_ClassType.h:180
#define zfnull
same as NULL, defined for future use
Definition ZFCoreTypeDef_CoreType.h:88
#define ZF_NAMESPACE_GLOBAL_BEGIN
begin namespace ZFFramework
Definition ZFNamespace.h:97
#define ZF_NAMESPACE_GLOBAL_END
end namespace ZFFramework
Definition ZFNamespace.h:98