Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032 #ifndef IZUnknownImplHelperHPP
00033 #define IZUnknownImplHelperHPP
00034
00035 #include <zeusbase/Config/PlatformDefines.hpp>
00036
00037
00038
00039
00043
00044 #define MEMORY_MANAGER_DECL \
00045 virtual NAMESPACE_Zeus::Retval MQUALIFIER askForInterface(const NAMESPACE_Zeus::InterfaceID& rInterfaceID, NAMESPACE_Zeus::IZUnknown*& rpIface);\
00046 virtual void MQUALIFIER addRef() const;\
00047 virtual void MQUALIFIER release() const;
00048
00049
00050
00051
00052
00053
00054 #define INTERFACE_CAST_START(classid) \
00055 NAMESPACE_Zeus::Retval MQUALIFIER classid::askForInterface(const NAMESPACE_Zeus::InterfaceID& rInterfaceID, NAMESPACE_Zeus::IZUnknown*& rpIface)\
00056 {
00057
00058
00059
00060
00061 #define INLINE_INTERFACE_CAST_START \
00062 NAMESPACE_Zeus::Retval MQUALIFIER askForInterface(const NAMESPACE_Zeus::InterfaceID& rInterfaceID, NAMESPACE_Zeus::IZUnknown*& rpIface)\
00063 {
00064
00065
00066
00073
00074 #define MEMORY_MANAGER_IMPL_PARENT(classid, parent) \
00075 typedef parent TempParent;\
00076 void MQUALIFIER classid::addRef() const\
00077 { \
00078 TempParent::addRef(); \
00079 } \
00080 void MQUALIFIER classid::release() const\
00081 { \
00082 TempParent::release(); \
00083 } \
00084 INTERFACE_CAST_START(classid)
00085
00086
00087
00093
00094 #define MEMORY_MANAGER_INLINEIMPL_PARENT(parent) \
00095 typedef parent TempParent;\
00096 void MQUALIFIER addRef() const\
00097 { \
00098 TempParent::addRef(); \
00099 } \
00100 void MQUALIFIER release() const\
00101 { \
00102 TempParent::release(); \
00103 } \
00104 INLINE_INTERFACE_CAST_START
00105
00106
00107
00113
00114 #define MEMORY_MANAGER_IMPL(classid) \
00115 MEMORY_MANAGER_IMPL_PARENT(classid, NAMESPACE_Zeus::TZObject)
00116
00117
00123
00124 #define MEMORY_MANAGER_INLINEIMPL() \
00125 MEMORY_MANAGER_INLINEIMPL_PARENT(NAMESPACE_Zeus::TZObject)
00126
00127
00128
00136
00137 #define MEMORY_MANAGER_IMPL_LOCK(classid, lock) \
00138 void MQUALIFIER classid::addRef() const\
00139 { \
00140 NAMESPACE_Zeus::TCriticalSection* pSection = (NAMESPACE_Zeus::TCriticalSection*)lock;\
00141 if (pSection != NULL)\
00142 { \
00143 pSection->enter();\
00144 } \
00145 typedef NAMESPACE_Zeus::TZObject TempTZObject;\
00146 TempTZObject::addRef(); \
00147 if (pSection != NULL)\
00148 { \
00149 pSection->leave();\
00150 }\
00151 } \
00152 void MQUALIFIER classid::release() const\
00153 { \
00154 NAMESPACE_Zeus::TCriticalSection* pSection = (NAMESPACE_Zeus::TCriticalSection*)lock;\
00155 if (pSection != NULL)\
00156 { \
00157 pSection->enter();\
00158 }\
00159 typedef NAMESPACE_Zeus::TZObject TempTZObject;\
00160 if (getRefCounter() == 1)\
00161 {\
00162 if (pSection != NULL)\
00163 { \
00164 pSection->leave();\
00165 }\
00166 TempTZObject::release(); \
00167 }\
00168 else\
00169 {\
00170 TempTZObject::release(); \
00171 if (pSection != NULL)\
00172 { \
00173 pSection->leave();\
00174 }\
00175 }\
00176 } \
00177 INTERFACE_CAST_START(classid)
00178
00179
00186
00187 #define INTERFACE_CAST(interface_type, interface_id) \
00188 INTERFACE_CAST_VAR(interface_type, interface_id, this)
00189
00190
00198
00199 #define INTERFACE_CAST_VAR(interface_type, interface_id, variable_) \
00200 typedef NAMESPACE_Zeus::TGUIDWrapper TempTGUIDWrapper;\
00201 if (TempTGUIDWrapper::isEqual(rInterfaceID, interface_id)) \
00202 {\
00203 rpIface = (interface_type*)variable_; \
00204 variable_->addRef(); \
00205 return RET_NOERROR; \
00206 }\
00207
00208
00209
00210
00211
00212
00213
00214
00215 #define MEMORY_MANAGER_IMPL_PARENT_END(parent) \
00216 typedef parent TempParent;\
00217 return TempParent::askForInterface(rInterfaceID, rpIface); \
00218 }
00219
00220
00221
00222
00223
00224
00225
00226
00227
00228
00229
00230
00231 #define MEMORY_MANAGER_IMPL_END \
00232 MEMORY_MANAGER_IMPL_PARENT_END(NAMESPACE_Zeus::TZObject)
00233
00234
00235
00242
00243 #define ICAST(variable) (NAMESPACE_Zeus::IZUnknown*&)variable
00244
00245
00246
00251
00252 #define HIDE_MEMORY_MANAGER_DEF \
00253 protected: \
00254 virtual NAMESPACE_Zeus::Retval MQUALIFIER askForInterface(const NAMESPACE_Zeus::InterfaceID& rInterfaceID, NAMESPACE_Zeus::IZUnknown*& rpIface)=0;\
00255 virtual void MQUALIFIER addRef() const=0;\
00256 virtual void MQUALIFIER release() const=0;
00257
00258
00259
00260
00261
00268
00269 #define MExportObjectFactory(InterFace, ClassName)\
00270 MODULE_EXPORT_PRE NAMESPACE_Zeus::Retval MODULE_EXPORT MQUALIFIER create##InterFace(NAMESPACE_Zeus::IZUnknown*& rpIface)\
00271 {\
00272 rpIface = (InterFace*)new ClassName();\
00273 return RET_NOERROR;\
00274 }\
00275
00276
00284
00285 #define MExportSerializableObject(InterFace, ClassName) \
00286 MExportObjectFactory(InterFace, ClassName)\
00287 MODULE_EXPORT_PRE NAMESPACE_Zeus::Retval MODULE_EXPORT MQUALIFIER deserialize##ClassName(Uint uiObjectID, IInputStream* pStream, IZUnknown*& rpObj)\
00288 {\
00289 return ClassName::createObject(uiObjectID, pStream, rpObj);\
00290 }\
00291
00292
00299
00300 #define MExportSingletonObject(InterFace, SingletonObj) \
00301 MODULE_EXPORT_PRE NAMESPACE_Zeus::Retval MODULE_EXPORT MQUALIFIER create##InterFace(NAMESPACE_Zeus::IZUnknown*& rpIface)\
00302 {\
00303 rpIface = (InterFace*)&SingletonObj;\
00304 SingletonObj.addRef(); \
00305 return RET_NOERROR;\
00306 }\
00307
00308
00309
00310
00318
00319 #ifdef ZEUS_DEBUG
00320 #define HIDE_ASSIGNMENT_OPERATOR(class_type) \
00321 private: \
00322 inline void operator=(const class_type& ) { }
00323 #else
00324 #define HIDE_ASSIGNMENT_OPERATOR(class_type)
00325 #endif
00326
00327
00335
00336 #ifdef ZEUS_DEBUG
00337 #define HIDE_DESTRUCTOR(class_type)
00338
00339
00340
00341
00342 #else
00343 #define HIDE_DESTRUCTOR(class_type)
00344 #endif
00345
00346
00347 #endif
00348