Symbian3/PDK/Source/GUID-2277BB1C-C04D-56C8-9B9B-FBC2EDCA9B07.dita
author Dominic Pinkman <Dominic.Pinkman@Nokia.com>
Tue, 30 Mar 2010 11:56:28 +0100
changeset 5 f345bda72bc4
parent 3 46218c8b8afa
child 14 578be2adaf3e
permissions -rw-r--r--
Week 12 contribution of PDK documentation_content. See release notes for details. Fixes Bug 2054, Bug 1583, Bug 381, Bug 390, Bug 463, Bug 1897, Bug 344, Bug 1319, Bug 394, Bug 1520, Bug 1522, Bug 1892"

<?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-2277BB1C-C04D-56C8-9B9B-FBC2EDCA9B07"><title>How to externalise and internalise compound objects</title><prolog><metadata><keywords/></metadata></prolog><conbody><p>Compound objects can be externalised and internalised. The only assumption is that all component objects (and their component objects) must be capable of being externalised and internalised.</p> <p>In this example, a compound object, an instance of the <codeph>CCompound</codeph> class, is externalised to, and internalised from, a single stream. The class is defined as:</p> <codeblock id="GUID-E6ACB6CF-C933-5C11-A773-F25EB05F8E73" xml:space="preserve">class CCompound : public CBase
    {
public :
    void ExternalizeL(RWriteStream&amp; aStream) const;
    void ExternalizeL(RReadStream&amp; aStream);
    ...
    CClassA* iCa;
    CClassB* iCb;
    TClassC  iTc;
    };</codeblock> <section><title>Externalising</title> <p>The preferred implementation of the <codeph>ExternalizeL()</codeph> function is:</p> <codeblock id="GUID-ED0746BB-7D2F-5274-BAF6-3FBF1781A0C3" xml:space="preserve">void CCompound::ExternalizeL(RWriteStream&amp; aStream) const
    {
    aStream &lt;&lt; *iCa;
    aStream &lt;&lt; *iCb;
    aStream &lt;&lt; iTc;
    }</codeblock> <p>The following implementation is also correct:</p> <codeblock id="GUID-2939633F-6FEB-596C-AE2F-DBBDB879B3E3" xml:space="preserve">void CCompound::ExternalizeL(RWriteStream&amp; aStream) const
    {
    iCa-&gt;ExternalizeL(aStream);
    iCb-&gt;ExternalizeL(aStream);
    iTc.ExternalizeL(aStream);
    }</codeblock> </section> <section><title>Internalising</title> <p>The preferred implementation of the <codeph>InternalizeL()</codeph> function is:</p> <codeblock id="GUID-60D0A0F9-A716-5EE2-AF31-D9927723BA12" xml:space="preserve">void CCompound::InternalizeL(RReadStream&amp; aStream)
    {
    aStream &gt;&gt; *iCa;
    aStream &gt;&gt; *iCb;
    aStream &gt;&gt;  iTc;
    }</codeblock> <p>The following implementation is also correct:</p> <codeblock id="GUID-E3DF0907-BE25-5D4E-A6FD-720CD70F9033" xml:space="preserve">void CCompound::InternalizeL(RReadStream&amp; aStream)
    {
    iCa-&gt;InternalizeL(aStream);
    iCb-&gt;InternalizeL(aStream);
    iTc.InternalizeL(aStream);
    }</codeblock> </section> </conbody></concept>