Symbian3/SDK/Source/GUID-2277BB1C-C04D-56C8-9B9B-FBC2EDCA9B07.dita
author Dominic Pinkman <dominic.pinkman@nokia.com>
Tue, 20 Jul 2010 12:00:49 +0100
changeset 13 48780e181b38
parent 0 89d6a7a84779
permissions -rw-r--r--
Week 28 contribution of SDK documentation content. See release notes for details. Fixes bugs Bug 1897 and Bug 1522.

<?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>