Symbian3/SDK/Source/GUID-6163197B-7983-5FB7-9B92-02E490A900FB.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 id="GUID-6163197B-7983-5FB7-9B92-02E490A900FB" xml:lang="en"><title>How to
       
    13 construct a header</title><shortdesc>This document describes how to create a header for a doubly linked
       
    14 list.</shortdesc><prolog><metadata><keywords/></metadata></prolog><conbody>
       
    15 <p>In order to construct a header, two important pieces of information are
       
    16 needed:</p>
       
    17 <ul>
       
    18 <li id="GUID-2E721D77-E010-5211-BABE-94578AECEEE4"><p>the <i>type</i> of object
       
    19 which forms the elements.</p> </li>
       
    20 <li id="GUID-71FC8FBF-803F-55BC-AC52-D672B1DA36BA"><p>the <i>offset</i> of
       
    21 the link object from the start of the element.</p> </li>
       
    22 </ul>
       
    23 <p>To create a header for a doubly linked list of <codeph>CMyClass</codeph> elements,
       
    24 defined as:</p>
       
    25 <codeblock id="GUID-D995F2F7-6A38-5EE3-9210-1302E1662759" xml:space="preserve">class CMyClass : public CBase
       
    26     {
       
    27     ...
       
    28     TDblQueLink iDlink;
       
    29     ...
       
    30     };</codeblock>
       
    31 <p>construct a <codeph>TDblQue</codeph> as follows:</p>
       
    32 <codeblock id="GUID-D13C33D2-EE7E-5915-92E2-F3EC5C772B4D" xml:space="preserve">TDblQue&lt;CMyClass&gt; queHeader(_FOFF(CMyClass,iDlink));</codeblock>
       
    33 <p>The <codeph>TDblQue</codeph> class takes a class template parameter which
       
    34 defines the type of object which is to form an element of the list. In this
       
    35 example, objects of type <codeph>CMyClass</codeph> form the elements of the
       
    36 list.</p>
       
    37 <p>The <codeph>_FOFF</codeph> macro (i.e. the "field offset" macro) calculates
       
    38 the offset of the component link object within the element. In this example,
       
    39 the required value is the offset of the <codeph>iDlink</codeph> data member
       
    40 from the start of <codeph>CMyClass</codeph>. </p>
       
    41 <fig id="GUID-9C102C34-EFFA-530A-AA1E-C6AE08FDFA37">
       
    42 <title/>
       
    43 <image href="GUID-29E7942D-A00D-5771-9782-59260965C687_d0e217648_href.png" placement="inline"/>
       
    44 </fig>
       
    45 </conbody></concept>