protocol definitions for ZFFramework More...
#include "ZFObject.h"
Go to the source code of this file.
Classes | |
class | v_ZFProtocolLevel |
level type for ZFProtocol, see ZFPROTOCOL_IMPLEMENTATION_BEGIN More... | |
class | v_ZFProtocolInstanceState |
instance state of ZFProtocol More... | |
class | ZFProtocol |
base class of all protocol of ZFFramework More... | |
class | v_ZFProtocol |
type wrapper for ZFTypeId::Value More... | |
class | ZFProtocolImplInfo |
see ZFProtocolImplInfoGetAll More... | |
class | v_ZFProtocolImplInfo |
type wrapper for ZFTypeId::Value More... | |
Macros | |
#define | ZFPROTOCOL_INTERFACE_CLASS(ModuleName) |
access the class name of ZFProtocol for ModuleName | |
#define | ZFPROTOCOL_INTERFACE_BEGIN(ZFLIB_, ModuleName) |
declare a protocol interface for ZFFramework | |
#define | ZFPROTOCOL_INTERFACE_END(ModuleName) |
for more information, please refer to ZFPROTOCOL_INTERFACE_BEGIN | |
#define | ZFPROTOCOL_INTERFACE_OPTIONAL |
macro to show that the protocol is optional | |
#define | ZFPROTOCOL_INTERFACE_REGISTER(ModuleName) |
statically register the protocol interface, must be placed in source file | |
#define | ZFPROTOCOL_TRY_ACCESS(ModuleName) |
access the protocol implementation | |
#define | ZFPROTOCOL_ACCESS(ModuleName) |
similar to ZFPROTOCOL_TRY_ACCESS, but assert fail if no implementation | |
#define | ZFPROTOCOL_IS_AVAILABLE(ModuleName) |
test whether the protocol is available | |
#define | ZFPROTOCOL_IMPLEMENTATION_PLATFORM_HINT(PlatformHint) |
register platform hint for an implementation, put it between ZFPROTOCOL_IMPLEMENTATION_BEGIN and ZFPROTOCOL_IMPLEMENTATION_END | |
#define | ZFPROTOCOL_IMPLEMENTATION_PLATFORM_DEPENDENCY_BEGIN() |
declare a dependency | |
#define | ZFPROTOCOL_IMPLEMENTATION_PLATFORM_DEPENDENCY_ITEM(Protocol, DependencyPlatformHint) |
see ZFPROTOCOL_IMPLEMENTATION_PLATFORM_DEPENDENCY_BEGIN | |
#define | ZFPROTOCOL_IMPLEMENTATION_PLATFORM_DEPENDENCY_END() |
see ZFPROTOCOL_IMPLEMENTATION_PLATFORM_DEPENDENCY_BEGIN | |
#define | ZFPROTOCOL_IMPLEMENTATION_CLASS(Implementation) |
the actual class name used by ZFPROTOCOL_IMPLEMENTATION_BEGIN | |
#define | ZFPROTOCOL_IMPLEMENTATION_BEGIN(ImplementationName, ModuleName, implLevel) |
declare a implementation for specified protocol interface named ModuleName | |
#define | ZFPROTOCOL_IMPLEMENTATION_END(ImplementationName) |
for more information, please refer to ZFPROTOCOL_IMPLEMENTATION_BEGIN | |
#define | ZFPROTOCOL_IMPLEMENTATION_CHECK(CheckAction) |
for more information, please refer to ZFPROTOCOL_IMPLEMENTATION_BEGIN | |
#define | ZFProtocolImplChange(ImplementationName) |
change the implementation at runtime | |
#define | ZFProtocolImplRemove(ModuleName) |
remove implementation, see ZFProtocolImplChange | |
Typedefs | |
typedef v_ZFProtocolLevel::ZFEnumType | ZFProtocolLevel |
see v_ZFProtocolLevel | |
typedef v_ZFProtocolInstanceState::ZFEnumType | ZFProtocolInstanceState |
see v_ZFProtocolInstanceState | |
Functions | |
zfbool | ZFProtocolLevelFromStringT (zfauto &ret, const zfchar *src, zfindex srcLen=((zfindex) -1), zfstring *errorHint=zft_zfnull) |
see v_ZFProtocolLevel, return enum object if success | |
zfbool | ZFProtocolLevelToStringT (zfstring &ret, v_ZFProtocolLevel *const &value, zfstring *errorHint=zft_zfnull) |
see ZFProtocolLevel, return empty string if error | |
zfstring | ZFProtocolLevelToString (v_ZFProtocolLevel *const &value, zfstring *errorHint=zft_zfnull) |
see v_ZFProtocolLevel, return empty string if error | |
const zfstring & | ZFTypeId_ZFProtocolLevel (void) |
zfbool | ZFProtocolLevelFromDataT (_ZFP_PropTypeW_ZFProtocolLevel &v, const ZFSerializableData &serializableData, zfstring *outErrorHint=zft_zfnull, ZFSerializableData *outErrorPos=zft_zfnull) |
see ZFTYPEID_DECLARE | |
_ZFP_PropTypeW_ZFProtocolLevel | ZFProtocolLevelFromData (const ZFSerializableData &serializableData, zfstring *outErrorHint=zft_zfnull, ZFSerializableData *outErrorPos=zft_zfnull) |
see ZFTYPEID_DECLARE | |
zfbool | ZFProtocolLevelToDataT (ZFSerializableData &serializableData, _ZFP_PropTypeW_ZFProtocolLevel const &v, zfstring *outErrorHint=zft_zfnull) |
see ZFTYPEID_DECLARE | |
ZFSerializableData | ZFProtocolLevelToData (_ZFP_PropTypeW_ZFProtocolLevel const &v, zfstring *outErrorHint=zft_zfnull) |
see ZFTYPEID_DECLARE | |
zfbool | ZFProtocolLevelFromStringT (_ZFP_PropTypeW_ZFProtocolLevel &v, const zfchar *src, zfindex srcLen=((zfindex) -1), zfstring *errorHint=zft_zfnull) |
util method to convert ZFProtocolLevel from string | |
_ZFP_PropTypeW_ZFProtocolLevel | ZFProtocolLevelFromString (const zfchar *src, zfindex srcLen=((zfindex) -1), zfstring *errorHint=zft_zfnull) |
util method to convert ZFProtocolLevel from string | |
zfbool | ZFProtocolLevelToStringT (zfstring &s, _ZFP_PropTypeW_ZFProtocolLevel const &v, zfstring *errorHint=zft_zfnull) |
util method to convert ZFProtocolLevel to string | |
zfstring | ZFProtocolLevelToString (_ZFP_PropTypeW_ZFProtocolLevel const &v, zfstring *errorHint=zft_zfnull) |
util method to convert ZFProtocolLevel to string | |
zfbool | ZFProtocolInstanceStateFromStringT (zfauto &ret, const zfchar *src, zfindex srcLen=((zfindex) -1), zfstring *errorHint=zft_zfnull) |
see v_ZFProtocolInstanceState, return enum object if success | |
zfbool | ZFProtocolInstanceStateToStringT (zfstring &ret, v_ZFProtocolInstanceState *const &value, zfstring *errorHint=zft_zfnull) |
see ZFProtocolInstanceState, return empty string if error | |
zfstring | ZFProtocolInstanceStateToString (v_ZFProtocolInstanceState *const &value, zfstring *errorHint=zft_zfnull) |
see v_ZFProtocolInstanceState, return empty string if error | |
const zfstring & | ZFTypeId_ZFProtocolInstanceState (void) |
zfbool | ZFProtocolInstanceStateFromDataT (_ZFP_PropTypeW_ZFProtocolInstanceState &v, const ZFSerializableData &serializableData, zfstring *outErrorHint=zft_zfnull, ZFSerializableData *outErrorPos=zft_zfnull) |
see ZFTYPEID_DECLARE | |
_ZFP_PropTypeW_ZFProtocolInstanceState | ZFProtocolInstanceStateFromData (const ZFSerializableData &serializableData, zfstring *outErrorHint=zft_zfnull, ZFSerializableData *outErrorPos=zft_zfnull) |
see ZFTYPEID_DECLARE | |
zfbool | ZFProtocolInstanceStateToDataT (ZFSerializableData &serializableData, _ZFP_PropTypeW_ZFProtocolInstanceState const &v, zfstring *outErrorHint=zft_zfnull) |
see ZFTYPEID_DECLARE | |
ZFSerializableData | ZFProtocolInstanceStateToData (_ZFP_PropTypeW_ZFProtocolInstanceState const &v, zfstring *outErrorHint=zft_zfnull) |
see ZFTYPEID_DECLARE | |
zfbool | ZFProtocolInstanceStateFromStringT (_ZFP_PropTypeW_ZFProtocolInstanceState &v, const zfchar *src, zfindex srcLen=((zfindex) -1), zfstring *errorHint=zft_zfnull) |
util method to convert ZFProtocolInstanceState from string | |
_ZFP_PropTypeW_ZFProtocolInstanceState | ZFProtocolInstanceStateFromString (const zfchar *src, zfindex srcLen=((zfindex) -1), zfstring *errorHint=zft_zfnull) |
util method to convert ZFProtocolInstanceState from string | |
zfbool | ZFProtocolInstanceStateToStringT (zfstring &s, _ZFP_PropTypeW_ZFProtocolInstanceState const &v, zfstring *errorHint=zft_zfnull) |
util method to convert ZFProtocolInstanceState to string | |
zfstring | ZFProtocolInstanceStateToString (_ZFP_PropTypeW_ZFProtocolInstanceState const &v, zfstring *errorHint=zft_zfnull) |
util method to convert ZFProtocolInstanceState to string | |
const zfstring & | ZFTypeId_ZFProtocol (void) |
ZFProtocol * | ZFProtocolForName (const zfchar *name, const zfchar *desiredImpl=(zft_zfnull)) |
get protocol with name or null if no such protocol | |
zfbool | ZFProtocolIsAvailable (const zfchar *name, const zfchar *desiredImpl=(zft_zfnull)) |
check whether protocol is available | |
const zfstring & | ZFTypeId_ZFProtocolImplInfo (void) |
ZFCoreArray< ZFProtocolImplInfo > | ZFProtocolImplInfoGetAll () |
for debug use only, get all protocol's info | |
ZFCoreArray< ZFProtocolImplInfo > | ZFProtocolImplInfoGetAllImplemented () |
util method to ZFProtocolImplInfoGetAll | |
ZFCoreArray< ZFProtocolImplInfo > | ZFProtocolImplInfoGetAllNotImplemented () |
util method to ZFProtocolImplInfoGetAll | |
void | ZFProtocolImplInfoPrint (const ZFOutput &callback=(ZFOutputDefault())) |
util method to ZFProtocolImplInfoGetAll | |
void | ZFProtocolImplInfoPrint (const ZFProtocolImplInfo &data, const ZFOutput &callback=(ZFOutputDefault())) |
util method to ZFProtocolImplInfoGetAll | |
protocol definitions for ZFFramework
#define ZFPROTOCOL_INTERFACE_CLASS | ( | ModuleName | ) |
access the class name of ZFProtocol for ModuleName
usually no use, unless the protocol module needs a constructor
#define ZFPROTOCOL_INTERFACE_BEGIN | ( | ZFLIB_, | |
ModuleName ) |
declare a protocol interface for ZFFramework
a protocol interface is a part that must be implemented, usually it's under Module/protocol such as ZFCore/protocol, meaning you should implement all protocols under ZFCore/protocol if you want to use ZFCore module
this macro is used internally to declare a protocol
typical usage:
for the difference between them, see ZFPROTOCOL_TRY_ACCESS
for how to implement it, see ZFPROTOCOL_IMPLEMENTATION_BEGIN
for how to access the implementation, see ZFPROTOCOL_TRY_ACCESS
#define ZFPROTOCOL_TRY_ACCESS | ( | ModuleName | ) |
access the protocol implementation
return protocol implementation or null if not implemented
typical usage:
all protocol is singleton protocol, ZFPROTOCOL_TRY_ACCESS would create new instance only for the first time, and the instance would be destroyed at a certain proper time
when using ZFPROTOCOL_TRY_ACCESS, you take full responsibility to check whether the implmentation is available
#define ZFPROTOCOL_IMPLEMENTATION_PLATFORM_HINT | ( | PlatformHint | ) |
register platform hint for an implementation, put it between ZFPROTOCOL_IMPLEMENTATION_BEGIN and ZFPROTOCOL_IMPLEMENTATION_END
while implementing protocol, you may use ZFPROTOCOL_IMPLEMENTATION_PLATFORM_DEPENDENCY_XXX to explicitly show it require other implementation
the PlatformHint can be any string, but you should make sure it's unique from others, and it's recommended to follow these rules (not necessary):
if you are able to access an implementation, you may check its platform hint by ZFProtocol::protocolImplPlatformHint
#define ZFPROTOCOL_IMPLEMENTATION_PLATFORM_DEPENDENCY_BEGIN | ( | ) |
declare a dependency
the DependencyPlatformHint is the string declared by ZFPROTOCOL_IMPLEMENTATION_PLATFORM_HINT
#define ZFPROTOCOL_IMPLEMENTATION_CLASS | ( | Implementation | ) |
the actual class name used by ZFPROTOCOL_IMPLEMENTATION_BEGIN
usually used to declare a constructor for protocol's implementation
#define ZFPROTOCOL_IMPLEMENTATION_BEGIN | ( | ImplementationName, | |
ModuleName, | |||
implLevel ) |
declare a implementation for specified protocol interface named ModuleName
for what ZFProtocol is, please refer to ZFPROTOCOL_INTERFACE_BEGIN
typical usage:
you must have exactly one implementation for each protocol interface if you want to use the specific module
to achieve this, you may want to use the #ifdef
the implementation's registration is automatically done by the BEGIN and END macro, what you should do, is to put it in a cpp file and make it active
the third param "implLevel", which has:
is used to specify the implementation level, ordered from low to high priority
for example, if you have a Default and a System level's implementation, the Default one would be overrided and the System one would be used.
however, if you have two same level's implementations, you would get duplicated implementation errors
for how to declare a protocol, see ZFPROTOCOL_INTERFACE_BEGIN
advanced:
you may change implementation at runtime, see ZFProtocolImplChange
you may define implementation which depends on other implementation:
#define ZFProtocolImplChange | ( | ImplementationName | ) |
change the implementation at runtime
old implementation's level is ignored and forced to be replaced
it's your responsibility to make sure old implementation isn't in use, otherwise, app may crash
|
inline |
|
inline |
|
inline |
|
extern |
get protocol with name or null if no such protocol
first param is the protocol's name (e.g. "ZFXml")
second param desiredImpl can be assigned to check whether the protocol matches what you want, see ZFPROTOCOL_IMPLEMENTATION_PLATFORM_HINT
|
extern |
check whether protocol is available
first param is the protocol's name (e.g. "ZFXml")
second param desiredImpl can be assigned to check whether the protocol matches what you want, see ZFPROTOCOL_IMPLEMENTATION_PLATFORM_HINT
|
inline |