Passing 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();
        }
    }

Related concepts