Symbian
Symbian Developer Library

SYMBIAN OS V9.4

Feedback

[Index] [Previous] [Next]


How to pass arguments from client to server classes

To make the animation architecture work, some mechanism is required to pass arguments across the client/server boundary. The window server acts as courier, but a packaging mechanism is still required if arbitrary information is to be passed through it. The following example is taken from an Anim DLL, which deals with handwriting.

On the client side, a struct (THandwritingDrawData) is packaged in a TPckgBuf templated argument descriptor and passed to the server-side CAnim instance via the RAnim::Command() function.

An opcode, EHwOpSetDrawData, is used by the server-side CAnim derived class to carry out some functionality.

The param()= expression sets the value of the THandwritingDrawData object inside the package to aDrawData.

void RHandWritingAnim::SetDrawData(const THandwritingDrawData& aDrawData)
    {
    TPckgBuf<THandwritingDrawData> param;
    param()=aDrawData;
    Command(EHwOpSetDrawData,param);
    }

The window server calls the CAnim::Command() function in response to application calls to the client side command function RAnim::Command(). The arguments passed to the function by the window server are the same as were used on the client side function call.

void CHandWritingAnim::Command(TInt aOpcode,TAny *aParams)
    {
    switch (aOpcode)
        {
        case EHwOpActivate:
            Activate();
            break;
        case EHwOpDeactivate:
            Deactivate();
            break;
        case EHwOpSetDrawData:;
            SetDrawData(STATIC_CAST(THandwritingDrawData*,aParams));
            break;
        default:
            iFunctions->Panic();
        }
    }

[Top]


See also

Using Package Buffers