ZFFramework
Loading...
Searching...
No Matches
ZFObjectRetain.h File Reference

retain count logic for ZFFramework More...

#include "ZFObjectCore.h"

Go to the source code of this file.

Macros

#define zfobjAlloc(T_ZFObject, ...)
 alloc an object, see ZFObject
#define zfunsafe_zfobjAlloc(T_ZFObject, ...)
 no lock version of zfobjAlloc, use with caution
#define zfobjRetain(obj)
 retain an object, see ZFObject
#define zfunsafe_zfobjRetain(obj)
 no lock version of zfobjRetain, use with caution
#define zfobjRelease(obj)
 release an object, see ZFObject
#define zfunsafe_zfobjRelease(obj)
 no lock version of zfobjRelease, use with caution

Functions

template<typename T_ZFObject, typename T_ZFObject2>
void zfobjRetainChange (T_ZFObject &obj, T_ZFObject2 const &v)
 util to release property's old value, retain new value, then set to property
template<typename T_ZFObject, typename T_ZFObject2>
void zfunsafe_zfobjRetainChange (T_ZFObject &obj, T_ZFObject2 const &v)
 no lock version of zfobjRetainChange, use with caution

Detailed Description

retain count logic for ZFFramework

Function Documentation

◆ zfobjRetainChange()

template<typename T_ZFObject, typename T_ZFObject2>
void zfobjRetainChange ( T_ZFObject & obj,
T_ZFObject2 const & v )
inline

util to release property's old value, retain new value, then set to property

this macro is similar to the retain property in Object-C
typical usage:

ZFObject *property = ...;
ZFObject *newProperty = ...;
// OK, release property, retain newProperty, then set to property
zfobjRetainChange(property, newProperty);
// OK, use return value of a function as new value
// but keep it in mind, that the new value will be retained
zfobjRetainChange(property, funcThatReturnZFObject());
// OK, same as release old property and set it to zfnull
// error, new value must be ZFObject
// zfobjRetainChange(property, 123);
// error, property must be a variable contains a (ZFObject *)
// zfobjRetainChange(zfnull, newProperty);
// zfobjRetainChange(funcThatReturnZFObject(), newProperty);
#define zfnull
same as NULL, defined for future use
Definition ZFCoreTypeDef_CoreType.h:88
void zfobjRetainChange(T_ZFObject &obj, T_ZFObject2 const &v)
util to release property's old value, retain new value, then set to property
Definition ZFObjectRetain.h:187
base class of all objects
Definition ZFObjectCore.h:195
See also
zfobjRetain, zfobjRelease, ZFPROPERTY_RETAIN