ZFFramework
 
Loading...
Searching...
No Matches
ZFKeyValueContainer.h
Go to the documentation of this file.
1
5
6#ifndef _ZFI_ZFKeyValueContainer_h_
7#define _ZFI_ZFKeyValueContainer_h_
8
9#include "ZFIterable.h"
11
12zfclassFwd _ZFP_ZFKeyValueContainerPrivate;
53zfabstract ZFLIB_ZFCore ZFKeyValueContainer: zfextend ZFObject, zfimplement ZFSerializable, zfimplement ZFCopyable, zfimplement ZFIterable, zfimplement ZFIterableKeyValue {
54 ZFOBJECT_DECLARE_ABSTRACT(ZFKeyValueContainer, ZFObject)
55 ZFIMPLEMENT_DECLARE(ZFSerializable, ZFCopyable, ZFIterable, ZFIterableKeyValue)
56
57public:
58 // ============================================================
59 // events
65 ZFEVENT(ContentOnUpdate)
73 ZFEVENT(ContentOnAdd)
81 ZFEVENT(ContentOnRemove)
82
83public:
87 virtual void addFrom(ZF_IN ZFKeyValueContainer *another) zfpurevirtual;
88
90 virtual void iterAdd(ZF_IN ZFObject *value) {ZFCoreCriticalNotSupported();}
91 virtual void iterAdd(
92 ZF_IN ZFObject *value
93 , ZF_IN_OUT zfiter &it
94 ) {
96 }
97 virtual void iterAdd(
98 ZF_IN ZFObject *key
99 , ZF_IN ZFObject *value
102
103public:
107 ZFMETHOD_DECLARE_3(void, objectInfoOfContentT
108 , ZFMP_IN_OUT(zfstring &, ret)
109 , ZFMP_IN_OPT(zfindex, maxCount, zfindexMax())
114 , ZFMP_IN_OPT(zfindex, maxCount, zfindexMax())
117
118protected:
120 virtual inline void contentOnUpdate(void) {
122 }
123
124 virtual inline void contentOnAdd(
125 ZF_IN ZFObject *key
126 , ZF_IN ZFObject *value
127 ) {
129 }
130
131 virtual inline void contentOnRemove(
132 ZF_IN ZFObject *key
133 , ZF_IN ZFObject *value
134 ) {
136 }
137
138protected:
143 ZF_IN const ZFSerializableData &serializableData
144 , ZF_OUT_OPT zfstring *outErrorHint = zfnull
145 , ZF_OUT_OPT ZFSerializableData *outErrorPos = zfnull
146 );
160 ZF_IN_OUT ZFSerializableData &serializableData
161 , ZF_OUT_OPT zfstring *outErrorHint = zfnull
162 , ZF_IN_OPT ZFSerializable *refOwner = zfnull
163 );
164protected:
169 ZF_IN_OUT ZFSerializableData &serializableData
170 , ZF_OUT_OPT zfstring *outErrorHint = zfnull
171 , ZF_IN_OPT ZFSerializable *refOwner = zfnull
172 );
173
174protected:
176 virtual void copyableOnCopyFrom(ZF_IN ZFObject *anotherObj);
177
178protected:
180 virtual void objectOnDeallocPrepare(void);
181
182public:
184 virtual void objectInfoImpl(ZF_IN_OUT zfstring &ret) {
185 this->objectInfoOfContentT(ret, 5);
186 }
187
189 virtual ZFCompareResult objectCompareValueImpl(ZF_IN ZFObject *anotherObj);
190};
191
193#endif // #ifndef _ZFI_ZFKeyValueContainer_h_
194
#define ZFLIB_ZFCore
used to export symbols
Definition ZFCoreEnvDef.h:30
#define ZFCoreCriticalNotSupported()
log that likes "[file function (line)] not supported"
Definition ZFCoreLog_CommonLog.h:143
#define ZF_OUT_OPT
dummy macro that shows the param used as optional output
Definition ZFCoreTypeDef_ClassType.h:192
#define zfextend
dummy macro shows class inherit from another
Definition ZFCoreTypeDef_ClassType.h:53
#define zfpurevirtual
dummy macro shows that a method is pure virtual method
Definition ZFCoreTypeDef_ClassType.h:68
#define zfoverride
dummy macro shows that method override parent's method
Definition ZFCoreTypeDef_ClassType.h:58
#define ZF_IN
dummy macro that shows the param used as required input
Definition ZFCoreTypeDef_ClassType.h:180
#define ZF_IN_OPT
dummy macro that shows the param used as optional 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:196
#define zfclassFwd
forward declaration of a class type
Definition ZFCoreTypeDef_ClassType.h:31
_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 zfindexMax()
(zfindex)-1, indicate a max index value, see zfindex
Definition ZFCoreTypeDef_CoreType.h:159
#define zfnull
same as NULL, defined for future use
Definition ZFCoreTypeDef_CoreType.h:88
ZFCompareResult
compare result of two ZFObjects
Definition ZFCoreTypeDef_OtherType.h:28
zft_zfstring< zfchar > zfstring
see zft_zfstring
Definition ZFCoreTypeDef_StringType.h:15
interface shows a ZFObject is iterable
#define ZFMP_IN_OUT(ParamType, paramName)
see ZFMP_IN
Definition ZFMethod.h:117
#define ZFMP_IN_OPT(ParamType, paramName, DefaultValue)
see ZFMP_IN
Definition ZFMethod.h:108
#define ZFMETHOD_DECLARE_2(ReturnType, MethodName, ZFMP_0, ZFMP_1)
see ZFMethod
Definition ZFMethodDeclare.h:1025
#define ZFMETHOD_DECLARE_3(ReturnType, MethodName, ZFMP_0, ZFMP_1, ZFMP_2)
see ZFMethod
Definition ZFMethodDeclare.h:1206
#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 zfabstract
typename for class showing that its abstract
Definition ZFObjectClassTypeFwd.h:42
#define ZFOBJECT_DECLARE_ABSTRACT(ChildClass, SuperClass,...)
necessary for every abstract class inherit from ZFObject
Definition ZFObjectDeclare.h:152
#define ZFIMPLEMENT_DECLARE(ImplementedInterfaces,...)
see ZFINTERFACE_DECLARE
Definition ZFObjectInterface.h:169
#define zfimplement
shows class implement from interface, see ZFInterface
Definition ZFObjectInterface.h:24
#define ZFEVENT(YourEvent)
see ZFObject::observerNotify
Definition ZFObjectObserver.h:328
#define ZFTokenForKeyValueContainerDefault()
see ZFTokenForKeyValueContainer, modifyable, ZFTokenForKeyValueContainerTrim by default
Definition ZFToken.h:214
virtual void iterAdd(ZFObject *value)=0
add value to tail
virtual zfbool serializableOnSerializeToDataWithRef(ZFSerializableData &serializableData, zfstring *outErrorHint=zft_zfnull, ZFSerializable *refOwner=zft_zfnull)
see ZFKeyValueContainer::serializableOnSerializeToData
virtual zfbool serializableOnCheck(void)
see serializable
virtual zfbool serializableOnSerializeToData(ZFSerializableData &serializableData, zfstring *outErrorHint=zft_zfnull, ZFSerializable *refOwner=zft_zfnull)
see ZFSerializable::serializableOnSerializeToData
virtual void contentOnUpdate(void)
see E_ContentOnUpdate
Definition ZFKeyValueContainer.h:120
virtual void objectInfoOfContentT(zfstring &ret, zfindex maxCount=(((zfindex) -1)), const ZFTokenForKeyValueContainer &token=(_ZFP_ZFTokenForKeyValueContainerDefault))
return a short string describe the content
virtual ZFCompareResult objectCompareValueImpl(ZFObject *anotherObj)
see objectCompareValue
static zfidentity E_ContentOnAdd(void)
see ZFObject::observerNotify
virtual zfstring objectInfoOfContent(zfindex maxCount=(((zfindex) -1)), const ZFTokenForKeyValueContainer &token=(_ZFP_ZFTokenForKeyValueContainerDefault))
see objectInfoOfContentT
virtual void copyableOnCopyFrom(ZFObject *anotherObj)
called by copy to copy contents from anotherObj
static zfidentity E_ContentOnUpdate(void)
see ZFObject::observerNotify
virtual void addFrom(ZFKeyValueContainer *another)=0
add data from another container
virtual void contentOnAdd(ZFObject *key, ZFObject *value)
see E_ContentOnAdd
Definition ZFKeyValueContainer.h:124
virtual void objectInfoImpl(zfstring &ret)
see objectInfo
Definition ZFKeyValueContainer.h:184
static zfidentity E_ContentOnRemove(void)
see ZFObject::observerNotify
virtual void contentOnRemove(ZFObject *key, ZFObject *value)
see E_ContentOnRemove
Definition ZFKeyValueContainer.h:131
virtual zfbool serializableOnSerializeFromData(const ZFSerializableData &serializableData, zfstring *outErrorHint=zft_zfnull, ZFSerializableData *outErrorPos=zft_zfnull)
for serializable data that has "category" attribute, ZFSerializable would ignore it and leave it to s...
virtual void objectOnDeallocPrepare(void)
called before objectOnDealloc, safe to call virtual functions here
base class of all objects
Definition ZFObjectCore.h:209
void observerNotify(zfidentity eventId, ZFObject *param0=zft_zfnull, ZFObject *param1=zft_zfnull)
notify the observer with eventId
ZFSerializable's data container, see ZFSerializable.
Definition ZFSerializableData.h:74
util class to hold string tokens
Definition ZFToken.h:113
iterator for ZFFramework
Definition zfiter.h:40