#include <zeusbase/System/ZObject.h>
#include <zeusbase/System/ZVariant.h>
#include <zeusbase/System/ByteArray.hpp>
#include <zeusbase/System/Stack.hpp>
#include <zeusbase/System/StringList.h>
#include <zeusbase/Remote/RemoteDefines.hpp>
#include <zeusbase/Remote/RemoteMethodCall.h>
#include <zeusbase/Remote/RemoteReference.h>
#include <zeusbase/Remote/Interfaces/IRemoteObjectStub.hpp>
Go to the source code of this file.
Classes |
| class | zeus::TAbstractStub |
Namespaces |
| namespace | zeus |
Defines |
| #define | STUB_CLASS_DECL(classid, classname) |
| #define | STUB_DELEGATION(name, method) |
| #define | STUB_PARAM(__name, __param) |
| #define | STUB_PARAM_REMOTEREF(__name, __param) |
| #define | STUB_RETURN_START |
| #define | STUB_RETPARAM_STRING(__name, __param) |
| #define | STUB_RETPARAM_STRING_PTR(__name, __param) |
| #define | STUB_RETPARAM_STRINGLIST(__name, __param) |
| #define | STUB_CREATE_STUB(__object, __stub) |
| #define | STUB_RETPARAM_REMOTEREF(__name, __param) |
| #define | STUB_RETPARAM_REMOTEREFLIST(__name, __param) |
| #define | STUB_RETVALUE_LONG(__retvar) |
| #define | STUB_RETVALUE_DOUBLE(__retvar) |
| #define | STUB_RETURN_END(__retvar) |
| #define | STUB_RETURN_ERRORCODE |
| #define | STUB_RETURN_VOID |
Define Documentation
| #define STUB_CLASS_DECL |
( |
|
classid, |
|
|
|
classname |
|
) |
| |
Value:public: \
static Retval MQUALIFIER createObject(Uint , IInputStream* pStream, IZUnknown*& rpObj) \
{ \
Retval retValue = RET_REQUEST_FAILED; \
\
if (pStream == NULL)\
{ \
rpObj = (IRemoteObject*)new classid();\
retValue = RET_NOERROR;\
} \
return retValue;\
} \
\
static void autoreg(bool reg)\
{ \
static Uint classid##Handle = 0;\
TString strClassName(classname); \
if (reg) \
{ \
classid##Handle = ZObjectFactory.registerClass(strClassName, createObject); \
} \
else \
{ \
ZObjectFactory.unregisterClass(strClassName, classid##Handle); \
} \
} \
Declaration of the stub class. This contains the autoregistration and factory method of the class (for ZObjectFactory)
- Parameters:
-
| classid | : ID of the class |
| classname | : Name of the class (String) |
| #define STUB_CREATE_STUB |
( |
|
__object, |
|
|
|
__stub |
|
) |
| |
Value:TRemoteReference* pRef = (TRemoteReference*)__object; \
if (pRef->createStub(&__stub) == RET_NOERROR) \
{ \
lstOutReferences.push(__stub); \
} \
else \
{ \
retValue = RET_UNREGISTERED_CLASS; \
} \
| #define STUB_DELEGATION |
( |
|
name, |
|
|
|
method |
|
) |
| |
Value:method \
{ \
Retval retValue = RET_REQUEST_FAILED; \
TRemoteMethodCall* pMethod = new TRemoteMethodCall(name); \
TStack<IZUnknown*> lstOutReferences;
Starts the delegation of a method call to the remote method call.
- Parameters:
-
| name | : Name of the method |
| method | : Method signature (something like: void classid::methodname ) |
| #define STUB_PARAM |
( |
|
__name, |
|
|
|
__param |
|
) |
| |
Value:{ \
TZVariant* pVar = new TZVariant(__name, __param); \
pMethod->addParameter(*pVar); \
pVar->release(); \
}
Transformation of a method parameter to the parameter of the remote method.
- Parameters:
-
| __name | : Name of the parameter (string) |
| __param | : Parameter of the method |
| #define STUB_PARAM_REMOTEREF |
( |
|
__name, |
|
|
|
__param |
|
) |
| |
Value:{ \
TRemoteReference* pRef = new TRemoteReference(__param); \
STUB_PARAM(__name, *pRef); \
pRef->release(); \
}
Transforms a remote object reference to a reference for remote method call. The __param could be a real object with interface IRemoteObject. This object must be transformed to a remote reference, which contains only data like address and port of the real remote object. Receiving such a reference by the skeleton, a stub will be created connecting to this real remote object.
- Parameters:
-
| __name | : Name of the parameter (string) |
| __param | : Parameter of the method |
| #define STUB_RETPARAM_REMOTEREF |
( |
|
__name, |
|
|
|
__param |
|
) |
| |
Value:Reads a return parameter as a remote object reference. Note that after a successfully return of the remote method call we receive a correct remote reference and a stub will be created automatically connecting to this remote reference.
- Parameters:
-
| __name | : Name of the parameter (string) |
| __param | : Parameter of the method |
| #define STUB_RETPARAM_REMOTEREFLIST |
( |
|
__name, |
|
|
|
__param |
|
) |
| |
Reads a return parameter as a remote object reference list. Note that after a successfully return of the remote method call we receive a correct remote reference and all stubs will be created automatically connecting to those remote references.
- Parameters:
-
| __name | : Name of the parameter (string) |
| __param | : Parameter of the method |
| #define STUB_RETPARAM_STRING |
( |
|
__name, |
|
|
|
__param |
|
) |
| |
Value:Reads a return parameter as a string (IString&)
- Parameters:
-
| __name | : Name of the parameter (string) |
| __param | : Parameter of the method |
| #define STUB_RETPARAM_STRING_PTR |
( |
|
__name, |
|
|
|
__param |
|
) |
| |
Value:Reads a return parameter as a string (IString*)
- Parameters:
-
| __name | : Name of the parameter (string) |
| __param | : Parameter of the method |
| #define STUB_RETPARAM_STRINGLIST |
( |
|
__name, |
|
|
|
__param |
|
) |
| |
Value:if (retValue == RET_NOERROR) \
{ \
TString strCountName = RPARAM_LIST_COUNT(__name); \
IZVariant* pCountVariant; \
if (pMethodReturn->getParameterByName(strCountName, pCountVariant) == RET_NOERROR) \
{ \
Int iCount = 0; \
pCountVariant->getInt32(iCount); \
for(Int i = 0; (i < iCount && retValue == RET_NOERROR); i++) \
{ \
TString strParamName = RPARAM_LIST_ITEM(__name, i); \
TString strParamValue; \
IString* pParamValuePtr = &strParamValue; \
STUB_RETPARAM_STRING_PTR(strParamName, pParamValuePtr); \
if (retValue == RET_NOERROR) \
{ \
__param->add(strParamValue);\
} \
} \
if (retValue != RET_NOERROR) \
{ \
__param->clear(); \
} \
pCountVariant->release(); \
} \
else \
{ \
retValue = RET_REMOTEPROTOCOL_ERROR; \
} \
}
Reads a return parameter as a string list IList<IString*>*
- Parameters:
-
| __name | : Name of the parameter (list) |
| __param | : Parameter of the method |
| #define STUB_RETURN_END |
( |
|
__retvar ) |
|
Value:pMethodReturn->release(); \
} \
pMethod->release(); \
if (retValue != RET_NOERROR)\
{ \
while(!lstOutReferences.isEmpty()) \
{ \
lstOutReferences.pop()->release(); \
} \
} \
return __retvar; \
}
Ends the return section
- Parameters:
-
| __retvar | : Variable to return of this method. |
| #define STUB_RETURN_ERRORCODE |
Value:This macro returns just the error code [retValue] of the stub method.
Value:IRemoteMethodCall* pMethodReturn = NULL; \
retValue = this->sendMethod(*pMethod, pMethodReturn);\
\
if (retValue == RET_NOERROR) \
{ \
Starts with all return (out) parameter and the return value. First it sends the remote method and after successfully receiving the response of the remote object we can start reading all return parameters.
- Note:
- This macro should be placed after the STUB_PARAM macros only.
-
To use [inout] parameters you have to place the parameter before (in) and once after this macro (out).
Value:pMethodReturn->release(); \
} \
pMethod->release(); \
}
Returns nothing. Use this for all methods having a [void] return.
| #define STUB_RETVALUE_DOUBLE |
( |
|
__retvar ) |
|
Value:if (retValue == RET_NOERROR) \
{ \
IZVariant* pRetVar = NULL; \
if (pMethodReturn->getReturnValue(pRetVar) == RET_NOERROR) \
{ \
if (pRetVar->getType() == IZVariant::etFloat64) \
{ \
pRetVar->getFloat64(__retvar); \
} \
else \
{ \
retValue = RET_REMOTEPROTOCOL_ERROR; \
} \
pRetVar->release(); \
} \
}
Reads a return value as double value
- Parameters:
-
| __retvar | : Variable which contains the return value of the method |
| #define STUB_RETVALUE_LONG |
( |
|
__retvar ) |
|
Value:if (retValue == RET_NOERROR) \
{ \
IZVariant* pRetVar = NULL; \
if (pMethodReturn->getReturnValue(pRetVar) == RET_NOERROR) \
{ \
if (pRetVar->getType() == IZVariant::etInt32) \
{ \
Int iVal = 0;\
pRetVar->getInt32(iVal); \
__retvar = iVal; \
} \
else \
{ \
retValue = RET_REMOTEPROTOCOL_ERROR; \
} \
pRetVar->release(); \
} \
}
Reads a return value as a int value
- Parameters:
-
| __retvar | : Variable which contains the return value of the method |