Symbian3/SDK/Source/GUID-FE3825C5-BDEE-5F18-9FFD-2E794E618FEC.dita
changeset 7 51a74ef9ed63
child 8 ae94777fff8f
equal deleted inserted replaced
6:43e37759235e 7:51a74ef9ed63
       
     1 <?xml version="1.0" encoding="utf-8"?>
       
     2 <!-- Copyright (c) 2007-2010 Nokia Corporation and/or its subsidiary(-ies) All rights reserved. -->
       
     3 <!-- This component and the accompanying materials are made available under the terms of the License 
       
     4 "Eclipse Public License v1.0" which accompanies this distribution, 
       
     5 and is available at the URL "http://www.eclipse.org/legal/epl-v10.html". -->
       
     6 <!-- Initial Contributors:
       
     7     Nokia Corporation - initial contribution.
       
     8 Contributors: 
       
     9 -->
       
    10 <!DOCTYPE concept
       
    11   PUBLIC "-//OASIS//DTD DITA Concept//EN" "concept.dtd">
       
    12 <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>
       
    13              Example : flow going downwards 
       
    14           </title> <image href="GUID-30987768-8B0A-5A35-820C-DBB410D2053B_d0e113991_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">
       
    15 void Send (RMBufChain &amp;aChain) 
       
    16 {
       
    17    TBuf8&lt;KHeaderLength&gt; aHeader;
       
    18    
       
    19    // [...] fill the header
       
    20 
       
    21    // request space in front of the data 
       
    22    aChain.Prepend(KHeaderLength);
       
    23 
       
    24    // add the protocol header
       
    25    aChain.CopyIn(aHeader);
       
    26 
       
    27    // send the updated chain to the next layer
       
    28    downwardComponent-&gt;Send(aChain);
       
    29 }
       
    30    </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>
       
    31              Example : flow going upwards 
       
    32           </title> <image href="GUID-11CBC0BA-3683-584A-9DC9-8BD3C9573F01_d0e114021_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">
       
    33 void Process (RMBufChain &amp;aChain)
       
    34 {
       
    35    TBuf8&lt;KHeaderLength&gt; aHeader;
       
    36    
       
    37    // get a copy of the header
       
    38    aChain.CopyOut(KHeaderLength, &amp;aHeader);
       
    39    
       
    40    // discard the header in the chain
       
    41    aChain.TrimStart(KHeaderLength);
       
    42 
       
    43    // [...] process the header
       
    44    
       
    45    // send the updated chain to the next layer
       
    46    appropriateUpwardComponent-&gt;Process(aChain);
       
    47 }
       
    48 </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)
       
    49                 and Comms Chains</linktext> </link> </related-links></concept>