Symbian3/SDK/Source/GUID-B756AB28-A0EA-5AA3-86E3-CCFFCD642F08.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-B756AB28-A0EA-5AA3-86E3-CCFFCD642F08" xml:lang="en"><title>What
       
    13 are links</title><shortdesc>This topic describes the structure of links. A link is a container
       
    14 and an element. A link is an item that can be stored in the Comms Database. </shortdesc><prolog><metadata><keywords/></metadata></prolog><conbody>
       
    15 <p>A link is a container. A link refers to another record. A link can be included
       
    16 in a record. </p>
       
    17 <p>A link is represented by the templated class <xref href="GUID-1CDD0B97-8B00-3373-9908-512C9BC1CF51.dita"><apiname>CMDBRecordLink&lt;T&gt;</apiname></xref>.
       
    18 The template parameter defines the type of record to which the link refers. </p>
       
    19 <fig id="GUID-0DFAC1B1-F79B-5C11-8EF3-13E70DBC5984">
       
    20 <image href="GUID-0FF61B9C-8B0D-5369-B0DA-29AA169B4308_d0e86440_href.png" placement="inline"/>
       
    21 </fig>
       
    22 <p>A link is a public data member of a class. The class defines the structure
       
    23 of record. This record is the 'parent' record of the linked record. For example,
       
    24 Symbian platform defines the class <xref href="GUID-1CDD0B97-8B00-3373-9908-512C9BC1CF51.dita"><apiname>CCDIAPRecord</apiname></xref> that
       
    25 represents an Internet Access Point (IAP) record. A set of IAP records form
       
    26 an IAP table. The public data members of this class are the fields and links
       
    27 that make the record. The following code shows part of the class definition.
       
    28 Some parts are omitted - this is not the complete class definition. </p>
       
    29 <codeblock id="GUID-AF4A223F-5A3F-53ED-B797-AB75BB80E174" xml:space="preserve">class CCDIAPRecord : public CCDRecordBase
       
    30     {
       
    31     public:
       
    32         CMDBField&lt;TDesC&gt;                        iServiceType;
       
    33         CMDBRecordLink&lt;CCDServiceRecordBase&gt;    iService;
       
    34         CMDBField&lt;TDesC&gt;                        iBearerType;
       
    35         CMDBRecordLink&lt;CCDBearerRecordBase&gt;     iBearer;
       
    36         CMDBRecordLink&lt;CCDNetworkRecord&gt;        iNetwork;
       
    37         CMDBField&lt;TUint32&gt;                      iNetworkWeighting;
       
    38         CMDBRecordLink&lt;CCDLocationRecord&gt;       iLocation;
       
    39         ...
       
    40     }
       
    41  </codeblock>
       
    42 <p>A <xref href="GUID-1CDD0B97-8B00-3373-9908-512C9BC1CF51.dita"><apiname>CMDBRecordLink&lt;T&gt;</apiname></xref> object contains
       
    43 an integer. The integer is the <xref href="GUID-6DAF85AD-E412-5823-81C2-FC1755A90A84.dita#GUID-6DAF85AD-E412-5823-81C2-FC1755A90A84/GUID-4DDD4947-D379-5B68-8DC0-B67B074FA852">element
       
    44 Id</xref> of the linked record in the database. </p>
       
    45 <p>If you have a parent record in memory, you call the <codeph>LoadL()</codeph> function
       
    46 on the link object <xref href="GUID-1CDD0B97-8B00-3373-9908-512C9BC1CF51.dita"><apiname>CMDBRecordLink&lt;T&gt;</apiname></xref> to
       
    47 get the linked record into memory. You can access the linked record through
       
    48 the <codeph>iLinkedRecord</codeph> pointer. This pointer is a member of the <codeph>CMDBRecordLinkBase</codeph> class,
       
    49 but you can access this data member through the <codeph>CMDBRecordLink&lt;T&gt;</codeph> object. </p>
       
    50 <p>There are two cases: </p>
       
    51 <ul>
       
    52 <li id="GUID-EB395834-73F0-592B-ADB0-0DB6499B534C"><p>If you know what type
       
    53 of record the link refers to you cast the pointer to the correct type. For
       
    54 example: </p> <codeblock id="GUID-A72D6DD6-31F4-5CB9-8688-810E33250DC7" xml:space="preserve">CCDDialOutISPRecord* ptrIspRecord = static_cast&lt;CCDDialOutISPRecord*&gt;(ptrSingleIAPRecord-&gt;iService.iLinkedRecord);</codeblock> <p>where <codeph>ptrSingleIAPRecord</codeph> is of type <xref href="GUID-1CDD0B97-8B00-3373-9908-512C9BC1CF51.dita"><apiname>CCDIAPRecord</apiname></xref>. </p> </li>
       
    55 <li id="GUID-A1E77CBE-3E79-55A1-9FA2-3CFF55C9FADB"><p>If you do not know what
       
    56 type of record the link refers to you cast the pointer to the base class for
       
    57 records. You use <codeph>GetFieldByNameL()</codeph> or <codeph>GetFieldByIdLaccess()</codeph> to
       
    58 access the data in the linked record. For example: </p> <codeblock id="GUID-684703C6-0754-5F69-91E1-6ED1202A0895" xml:space="preserve">CCDServiceRecordBase* ptrServiceRecord = static_cast&lt;CCDServiceRecordBase*&gt;(ptrSingleIAPRecord-&gt;iService.iLinkedRecord);
       
    59 CMDBField&lt;TUint32&gt;* field; 
       
    60 
       
    61 // Find a field by its Id. In this code fragment, the field we are looking for 
       
    62 // is the bearer speed field.
       
    63 field = (CMDBField&lt;TUint32&gt;*)ptrServiceRecord-&gt;GetFieldByIdL(KCDTIdBearerSpeed);</codeblock> </li>
       
    64 </ul>
       
    65 </conbody><related-links>
       
    66 <link href="GUID-9D56FF77-A20B-5BFB-8DE6-19CC4535DFED.dita"><linktext>Following
       
    67                 a link to another table and finding a field by Id and by name:
       
    68 Tutorial</linktext></link>
       
    69 </related-links></concept>