Week 23 contribution of PDK 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 id="GUID-6163197B-7983-5FB7-9B92-02E490A900FB" xml:lang="en"><title>How to
construct a header</title><shortdesc>This document describes how to create a header for a doubly linked
list.</shortdesc><prolog><metadata><keywords/></metadata></prolog><conbody>
<p>In order to construct a header, two important pieces of information are
needed:</p>
<ul>
<li id="GUID-2E721D77-E010-5211-BABE-94578AECEEE4"><p>the <i>type</i> of object
which forms the elements.</p> </li>
<li id="GUID-71FC8FBF-803F-55BC-AC52-D672B1DA36BA"><p>the <i>offset</i> of
the link object from the start of the element.</p> </li>
</ul>
<p>To create a header for a doubly linked list of <codeph>CMyClass</codeph> elements,
defined as:</p>
<codeblock id="GUID-D995F2F7-6A38-5EE3-9210-1302E1662759" xml:space="preserve">class CMyClass : public CBase
{
...
TDblQueLink iDlink;
...
};</codeblock>
<p>construct a <codeph>TDblQue</codeph> as follows:</p>
<codeblock id="GUID-D13C33D2-EE7E-5915-92E2-F3EC5C772B4D" xml:space="preserve">TDblQue<CMyClass> queHeader(_FOFF(CMyClass,iDlink));</codeblock>
<p>The <codeph>TDblQue</codeph> class takes a class template parameter which
defines the type of object which is to form an element of the list. In this
example, objects of type <codeph>CMyClass</codeph> form the elements of the
list.</p>
<p>The <codeph>_FOFF</codeph> macro (i.e. the "field offset" macro) calculates
the offset of the component link object within the element. In this example,
the required value is the offset of the <codeph>iDlink</codeph> data member
from the start of <codeph>CMyClass</codeph>. </p>
<fig id="GUID-9C102C34-EFFA-530A-AA1E-C6AE08FDFA37">
<title/>
<image href="GUID-29E7942D-A00D-5771-9782-59260965C687_d0e213911_href.png" placement="inline"/>
</fig>
</conbody></concept>