ZFFramework
 
Loading...
Searching...
No Matches
ZFCallbackSerializable.h
Go to the documentation of this file.
1
5
6#ifndef _ZFI_ZFCallbackSerializable_h_
7#define _ZFI_ZFCallbackSerializable_h_
8
9#include "ZFIOCallback.h"
10#include "ZFSerializable.h"
11#include "ZFTypeId.h"
13
44ZFOUTPUT_TYPE(ZFCallback, {v.objectInfoT(s);})
45
48
51
52// ============================================================
53_ZFP_ZFCALLBACK_DECLARE_END_REG(ZFLIB_ZFCore, ZFListener, ZFCallback)
54_ZFP_ZFCALLBACK_DECLARE_END_REG(ZFLIB_ZFCore, ZFIOCallback, ZFCallback)
55_ZFP_ZFCALLBACK_DECLARE_END_REG(ZFLIB_ZFCore, ZFOutput, ZFIOCallback)
56_ZFP_ZFCALLBACK_DECLARE_END_REG(ZFLIB_ZFCore, ZFInput, ZFIOCallback)
57
58// ============================================================
59// custom serialize logic
60typedef zfbool (*_ZFP_ZFCallbackSerializeCustomCallback)(
62 , ZF_IN const ZFSerializableData &serializableData
63 , ZF_OUT_OPT zfstring *outErrorHint /* = zfnull */
64 , ZF_OUT_OPT ZFSerializableData *outErrorPos /* = zfnull */
65 );
66extern ZFLIB_ZFCore void _ZFP_ZFCallbackSerializeCustomTypeRegister(
67 ZF_IN const zfstring &customType
68 , ZF_IN _ZFP_ZFCallbackSerializeCustomCallback serializeCallback
69 );
70extern ZFLIB_ZFCore void _ZFP_ZFCallbackSerializeCustomTypeUnregister(ZF_IN const zfstring &customType);
71extern ZFLIB_ZFCore _ZFP_ZFCallbackSerializeCustomCallback _ZFP_ZFCallbackSerializeCustomTypeForName(ZF_IN const zfstring &customType);
72
92#define ZFCALLBACK_SERIALIZE_TYPE_DEFINE(registerSig, type) \
93 static zfbool _ZFP_ZFCallbackSerializeCustom_##registerSig(ZF_IN_OUT ZFCallback &ret, \
94 ZF_IN const ZFSerializableData &serializableData, \
95 ZF_OUT_OPT zfstring *outErrorHint /* = zfnull */, \
96 ZF_OUT_OPT ZFSerializableData *outErrorPos /* = zfnull */); \
97 ZF_GLOBAL_INITIALIZER_INIT_WITH_LEVEL(ZFCallbackSerializeCustomTypeReg_##registerSig, ZFLevelZFFrameworkNormal) { \
98 _ZFP_ZFCallbackSerializeCustomTypeRegister(type, _ZFP_ZFCallbackSerializeCustom_##registerSig); \
99 } \
100 ZF_GLOBAL_INITIALIZER_DESTROY(ZFCallbackSerializeCustomTypeReg_##registerSig) { \
101 _ZFP_ZFCallbackSerializeCustomTypeUnregister(type); \
102 } \
103 ZF_GLOBAL_INITIALIZER_END(ZFCallbackSerializeCustomTypeReg_##registerSig) \
104 static zfbool _ZFP_ZFCallbackSerializeCustom_##registerSig(ZF_IN_OUT ZFCallback &ret, \
105 ZF_IN const ZFSerializableData &serializableData, \
106 ZF_OUT_OPT zfstring *outErrorHint /* = zfnull */, \
107 ZF_OUT_OPT ZFSerializableData *outErrorPos /* = zfnull */)
108
110#endif // #ifndef _ZFI_ZFCallbackSerializable_h_
111
#define ZFSerializableKeyword_ZFCallback_callbackType
keyword for serialize
Definition ZFCallbackSerializable.h:50
#define ZFSerializableKeyword_ZFCallback_method
keyword for serialize
Definition ZFCallbackSerializable.h:47
#define ZFLIB_ZFCore
used to export symbols
Definition ZFCoreEnvDef.h:30
#define ZF_OUT_OPT
dummy macro that shows the param used as optional output
Definition ZFCoreTypeDef_ClassType.h:196
#define ZF_IN
dummy macro that shows the param used as required input
Definition ZFCoreTypeDef_ClassType.h:184
#define ZF_IN_OUT
dummy macro that shows the param used as required input and output
Definition ZFCoreTypeDef_ClassType.h:200
_ZFT_t_zfbool zfbool
bool type
Definition ZFCoreTypeDef_CoreType.h:103
#define ZFOUTPUT_TYPE(T_Type, outputAction)
declare your custom type conversion to string, convenient for debug
Definition ZFCoreTypeDef_OtherType.h:221
zft_zfstring< zfchar > zfstring
see zft_zfstring
Definition ZFCoreTypeDef_StringType.h:15
common callback defines
#define ZF_NAMESPACE_GLOBAL_BEGIN
begin namespace ZFFramework
Definition ZFNamespace.h:97
#define ZF_NAMESPACE_GLOBAL_END
end namespace ZFFramework
Definition ZFNamespace.h:98
serializable interface
reflectable type define
#define ZFTYPEID_DECLARE(ZFLIB_, TypeName, Type)
register a type for reflection
Definition ZFTypeIdDeclare.h:137
#define ZFTYPEID_REG(ZFLIB_, TypeName, Type,...)
see ZFTYPEID_DECLARE
Definition ZFTypeIdDeclare.h:151
callback used by ZFFramework
Definition ZFCallback.h:98
abstract base class, use ZFOutput or ZFInput
Definition ZFIOCallback_fwd.h:62
general input callback
Definition ZFIOCallback_input.h:36
listener as ZFCallback, mostly used by ZFObject::observerNotify
Definition ZFObjectObserver.h:30
general output callback
Definition ZFIOCallback_output.h:37
ZFSerializable's data container, see ZFSerializable.
Definition ZFSerializableData.h:74