ZFFramework
 
Loading...
Searching...
No Matches
zfautoFwd.h
Go to the documentation of this file.
1
5
6#ifndef _ZFI_zfautoFwd_h_
7#define _ZFI_zfautoFwd_h_
8
9#include "zfany.h"
10
12
13// ============================================================
14// zfauto
36public:
37 zfauto(void) : _ZFP_obj(zfnull) {}
38 zfauto(ZF_IN zfauto const &obj);
39 zfauto(ZF_IN ZFObject *obj);
40 template<typename T_ZFObject>
41 zfauto(ZF_IN T_ZFObject const &obj);
42 zffinal ~zfauto(void);
43
44public:
45 zfauto &operator = (ZF_IN zfauto const &obj);
46 template<typename T_ZFObject>
47 zfauto &operator = (ZF_IN T_ZFObject const &obj);
48
49public:
50 template<typename T_ZFObject>
51 inline zfbool operator == (ZF_IN T_ZFObject const &obj) const {
52 return this->toObject() == _ZFP_zfanyCast(obj);
53 }
54 template<typename T_ZFObject>
55 inline zfbool operator != (ZF_IN T_ZFObject const &obj) const {
56 return this->toObject() != _ZFP_zfanyCast(obj);
57 }
58
59public:
60 inline ZFObject *operator -> (void) const {
61 return this->toObject();
62 }
63 inline operator zfbool (void) const {
64 return (zfbool)_ZFP_obj;
65 }
66 inline operator ZFObject * (void) const {
67 return this->toObject();
68 }
69 template<typename T_ZFObject>
70 inline operator T_ZFObject * (void) const;
71
72public:
73 static const ZFClass *ClassData(void);
75
76public:
80 const zfany &asAny(void) const {
81 return _ZFP_obj;
82 }
83
94 inline ZFObject *toObject(void) const {
95 return _ZFP_obj;
96 }
97
100 template<typename T_ZFObject>
101 inline T_ZFObject to(void) const;
102
103private:
104 zfany _ZFP_obj;
105};
106
107// ============================================================
108// zfautoT
112template<typename T_ZFObjectBase>
115public:
116 zfautoT(void) : zfauto() {}
117 zfautoT(ZF_IN zfauto const &obj) : zfauto(obj) {}
118 zfautoT(ZF_IN zfautoT<T_ZFObjectBase> const &obj) : zfauto((zfauto const &)obj) {}
119 zfautoT(ZF_IN ZFObject *obj) : zfauto(obj) {}
120 template<typename T_ZFObject>
121 zfautoT(ZF_IN T_ZFObject const &obj) : zfauto(obj) {}
122
123public:
124 inline zfautoT<T_ZFObjectBase> &operator = (ZF_IN zfauto const &obj) {
125 zfauto::operator = (obj);
126 return *this;
127 }
128 inline zfautoT<T_ZFObjectBase> &operator = (ZF_IN zfautoT<T_ZFObjectBase> const &obj) {
129 zfauto::operator = ((zfauto const &)obj);
130 return *this;
131 }
132 template<typename T_ZFObject>
133 inline zfautoT<T_ZFObjectBase> &operator = (ZF_IN T_ZFObject const &obj) {
134 zfauto::operator = (obj);
135 return *this;
136 }
137
138public:
139 template<typename T_ZFObject>
140 inline zfbool operator == (ZF_IN T_ZFObject const &obj) const {
141 return this->toObject() == _ZFP_zfanyCast(obj);
142 }
143 template<typename T_ZFObject>
144 inline zfbool operator != (ZF_IN T_ZFObject const &obj) const {
145 return this->toObject() != _ZFP_zfanyCast(obj);
146 }
147
148public:
149 T_ZFObjectBase *operator -> (void) const;
150
151public:
152 inline ZFObject *toObject(void) const { // required for _ZFP_zfanyCast to work
153 return zfauto::toObject();
154 }
155
156public:
157 static const ZFClass *ClassData(void);
159};
160
162// ============================================================
163template<typename T_ZFObject>
164inline zfbool operator == (ZF_IN T_ZFObject *obj, ZF_IN zfauto const &e) {
165 return e.toObject() == _ZFP_zfanyCast(obj);
166}
167template<typename T_ZFObject>
168inline zfbool operator != (ZF_IN T_ZFObject *obj, ZF_IN zfauto const &e) {
169 return e.toObject() != _ZFP_zfanyCast(obj);
170}
171
172// ============================================================
173template<typename T_ZFObject, typename T_ZFObjectBase>
174inline zfbool operator == (ZF_IN T_ZFObject *obj, ZF_IN zfautoT<T_ZFObjectBase> const &e) {
175 return e.toObject() == _ZFP_zfanyCast(obj);
176}
177template<typename T_ZFObject, typename T_ZFObjectBase>
178inline zfbool operator != (ZF_IN T_ZFObject *obj, ZF_IN zfautoT<T_ZFObjectBase> const &e) {
179 return e.toObject() != _ZFP_zfanyCast(obj);
180}
182
184
185#endif // #ifndef _ZFI_zfautoFwd_h_
186
#define ZFLIB_ZFCore
used to export symbols
Definition ZFCoreEnvDef.h:30
#define zffinal
dummy macro shows that a method or class is designed must not to be overrided
Definition ZFCoreTypeDef_ClassType.h:63
#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 zfextend
dummy macro shows class inherit from another
Definition ZFCoreTypeDef_ClassType.h:53
#define ZF_IN
dummy macro that shows the param used as required input
Definition ZFCoreTypeDef_ClassType.h:180
_ZFT_t_zfbool zfbool
bool type
Definition ZFCoreTypeDef_CoreType.h:103
_ZFT_t_zfindex zfindex
similar to size_t, used for index and size only
Definition ZFCoreTypeDef_CoreType.h:154
#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
ZFObject's class info.
Definition ZFClass.h:66
base class of all objects
Definition ZFObjectCore.h:205
util method to cast ZFObject types freely
Definition zfany.h:35
a ZFObject holder which would release content object automatically when destroyed
Definition zfautoFwd.h:34
T_ZFObject to(void) const
cast by zfcast
void zfunsafe_assign(ZFObject *obj)
no lock version of object assign, for low level impl only
ZFObject * toObject(void) const
get the holded object
Definition zfautoFwd.h:94
zfindex objectRetainCount(void) const
get current retain count
const zfany & asAny(void) const
access as zfany
Definition zfautoFwd.h:80
type restrict version of zfauto
Definition zfautoFwd.h:113
util class to cast ZFObject types freely