Symbian3/SDK/Source/GUID-FE3825C5-BDEE-5F18-9FFD-2E794E618FEC.dita
author Dominic Pinkman <dominic.pinkman@nokia.com>
Fri, 11 Jun 2010 12:39:03 +0100
changeset 8 ae94777fff8f
parent 7 51a74ef9ed63
child 13 48780e181b38
permissions -rw-r--r--
Week 23 contribution of SDK documentation content. See release notes for details. Fixes bugs Bug 2714, Bug 462.

<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright (c) 2007-2010 Nokia Corporation and/or its subsidiary(-ies) All rights reserved. -->
<!-- This component and the accompanying materials are made available under the terms of the License 
"Eclipse Public License v1.0" which accompanies this distribution, 
and is available at the URL "http://www.eclipse.org/legal/epl-v10.html". -->
<!-- Initial Contributors:
    Nokia Corporation - initial contribution.
Contributors: 
-->
<!DOCTYPE concept
  PUBLIC "-//OASIS//DTD DITA Concept//EN" "concept.dtd">
<concept xml:lang="en" id="GUID-FE3825C5-BDEE-5F18-9FFD-2E794E618FEC"><title>Data Access Example</title><shortdesc>This example describes typical processing of the data in an RMBufChain. </shortdesc><prolog><metadata><keywords/></metadata></prolog><conbody><section><title>Downwards flow</title> <fig id="GUID-43219AE7-A0E4-570A-98ED-07D44D849979"><title>
             Example : flow going downwards 
          </title> <image href="GUID-30987768-8B0A-5A35-820C-DBB410D2053B_d0e107453_href.png" placement="inline"/></fig> <p>The following function is a simplified example of how a component in the middle of the stack could process data sent to the driver. As shown in the above diagram, the upper layer provides the data in the <codeph>RMBufChain</codeph> parameter. </p> <codeblock id="GUID-4C87CEB3-DCFD-5765-BF89-6EF9275EB584" xml:space="preserve">
void Send (RMBufChain &amp;aChain) 
{
   TBuf8&lt;KHeaderLength&gt; aHeader;
   
   // [...] fill the header

   // request space in front of the data 
   aChain.Prepend(KHeaderLength);

   // add the protocol header
   aChain.CopyIn(aHeader);

   // send the updated chain to the next layer
   downwardComponent-&gt;Send(aChain);
}
   </codeblock> <p>Note that depending on the available space remaining in front of the data in the MBuf, the <xref href="GUID-F024208C-ED19-3301-85C1-53F397C9910F.dita#GUID-F024208C-ED19-3301-85C1-53F397C9910F/GUID-A7CEF452-AB4E-378C-A262-B1C5FCBA68BB"><apiname>RMBufChain::Prepend()</apiname></xref> method may request the pond to add a new MBuf to the front of the chain. For more information, see <xref href="GUID-B4F15CA3-CAD4-5A87-9610-A656CA337B72.dita#GUID-B4F15CA3-CAD4-5A87-9610-A656CA337B72/GUID-5EBCD46C-5E07-5DB1-90D9-6A5CA3E36C0B">Buffer layout</xref>. </p> </section> <section><title>Upwards flow</title> <fig id="GUID-402331EB-6DE8-5DC5-9FF7-7D5DD8D816D5"><title>
             Example : flow going upwards 
          </title> <image href="GUID-11CBC0BA-3683-584A-9DC9-8BD3C9573F01_d0e107483_href.png" placement="inline"/></fig> <p>The following function is a simplified example of how a component in the middle of the stack could process data received by the driver. As shown in the above diagram, the underlying layer provides the data in the <codeph>RMBufChain</codeph> parameter. </p> <codeblock id="GUID-C36656D9-AEB0-5DBF-A469-0183F80AE057" xml:space="preserve">
void Process (RMBufChain &amp;aChain)
{
   TBuf8&lt;KHeaderLength&gt; aHeader;
   
   // get a copy of the header
   aChain.CopyOut(KHeaderLength, &amp;aHeader);
   
   // discard the header in the chain
   aChain.TrimStart(KHeaderLength);

   // [...] process the header
   
   // send the updated chain to the next layer
   appropriateUpwardComponent-&gt;Process(aChain);
}
</codeblock> <p>Note that the header might not be stored in a contiguous memory area: it can be splitted accross several chained MBufs. For a better performance, you should define a buffer size slightly bigger than your MTU: for more information, see <xref href="GUID-6FEE5676-8BFB-53E6-A652-7178295C342E.dita#GUID-6FEE5676-8BFB-53E6-A652-7178295C342E/GUID-8F0E62BA-455A-5C58-9AB1-70C79F5BA573">Pond Configuration : Recommendations</xref>. </p> </section> </conbody><related-links><link href="GUID-55E4D84B-1B90-5BA4-9CE0-6D26EA208F13.dita"><linktext>Overview</linktext> </link> <link href="GUID-B4F15CA3-CAD4-5A87-9610-A656CA337B72.dita"><linktext>Comms Buffers (MBuf)
                and Comms Chains</linktext> </link> </related-links></concept>