ZFFramework
 
Loading...
Searching...
No Matches
ZFCopyable.h
Go to the documentation of this file.
1
5
6#ifndef _ZFI_ZFCopyable_h_
7#define _ZFI_ZFCopyable_h_
8
9#include "ZFObjectCore.h"
11
15zfinterface ZFLIB_ZFCore ZFCopyable : zfextend ZFInterface {
16 ZFINTERFACE_DECLARE(ZFCopyable, ZFInterface)
17
18public:
27 zffinal void copyFrom(ZF_IN ZFObject *anotherObj);
28
29protected:
38 virtual inline void copyableOnCopyFrom(ZF_IN ZFObject *anotherObj) {
39 }
40};
41
46 ZFCopyable *t = zfcast(ZFCopyable *, obj);
47 if(t) {
48 return t->copy();
49 }
50 else {
51 return zfnull;
52 }
53}
54
56#endif // #ifndef _ZFI_ZFCopyable_h_
57
zfauto ZFObjectCopy(ZFObject *obj)
util to copy as ZFCopyable or return null if not available
Definition ZFCopyable.h:45
#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 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
#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
#define zfcast(T_To, obj)
safely cast ZFObject types, return null if not desired type
Definition ZFObjectCast.h:28
base class of all objects
#define zfinterface
shows the type is an interface, see ZFInterface
Definition ZFObjectInterface.h:20
#define ZFINTERFACE_DECLARE(InterfaceName, ParentInterface,...)
see ZFInterface
Definition ZFObjectInterface.h:100
interface shows a ZFObject is copyable
Definition ZFCopyable.h:15
virtual void copyableOnCopyFrom(ZFObject *anotherObj)
called by copy to copy contents from anotherObj
Definition ZFCopyable.h:38
zfautoT< ZFCopyable > copy(void)
return a copy of this object
void copyFrom(ZFObject *anotherObj)
see copy, anotherObj must be same type as this object (by classData), otherwise, do nothing
base class of all objects
Definition ZFObjectCore.h:209
a ZFObject holder which would release content object automatically when destroyed
Definition zfautoFwd.h:34
type restrict version of zfauto
Definition zfautoFwd.h:110