Symbian3/SDK/Source/GUID-95448841-5E5B-54C4-85A7-DCE6D078E036.dita
author Graeme Price <GRAEME.PRICE@NOKIA.COM>
Fri, 15 Oct 2010 14:32:18 +0100
changeset 15 307f4279f433
parent 7 51a74ef9ed63
permissions -rw-r--r--
Initial contribution of the Adaptation Documentation.

<?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-95448841-5E5B-54C4-85A7-DCE6D078E036" xml:lang="en"><title>Constructing
an embedded store</title><shortdesc>Embedded stores are represented by an instance of the <codeph>CEmbeddedStore</codeph> class.</shortdesc><prolog><metadata><keywords/></metadata></prolog><conbody>
<p>A <codeph>CEmbeddedStore</codeph> object is constructed from a host stream. </p>
<p>When the <codeph>CEmbeddedStore</codeph> object represents a new embedded
store, it is constructed from an <codeph>RWriteStream</codeph> object; for
example, a class might include the following code fragment in one of its functions:</p>
<codeblock id="GUID-47D69E5D-909D-5EA3-96CD-3FB6ED5E77CB" xml:space="preserve">...
    // create the stream to contain the embedded store
RStoreWriteStream childStream;
                // we need to keep track of this stream id
iEmbeddedStoreId = childStream.CreateLC(iStore);
    // construct the embedded store
CPersistentStore* embeddedStore = CEmbeddedStore::NewLC(childStream);
...</codeblock>
<p>Here, the code assumes that <codeph>iStore</codeph> refers to the top level
store and <codeph>iEmbeddedStoreId</codeph> is a data member to hold the ID
of the hosting stream.</p>
<p>On successful construction, ownership of the host stream passes to the
embedded store which means that the embedded store takes on the responsibility
for closing the stream.</p>
<p>When the <codeph>CEmbeddedStore</codeph> object represents an existing
embedded store, it is constructed from an <codeph>RReadStream</codeph> object;
for example, a class might include the following code fragment in one of its
functions:</p>
<codeblock id="GUID-A796CC6C-69C9-5F22-B7A1-30815086EAA3" xml:space="preserve">...
RStoreReadStream childStream;
childStream.OpenL(iStore,iEmbeddedStoreId);
iEmbeddedStore = CEmbeddedStore::FromL(childStream);
...</codeblock>
<p>Where:</p>
<ul>
<li id="GUID-7A3338F6-252E-5D47-9D22-CDD505222958"><p><codeph>iStore</codeph> refers
to the top level store</p> </li>
<li id="GUID-162A3315-AA91-55CD-B07A-2F02EDBCC5ED"><p><codeph>iEmbeddedStoreId</codeph> is
a data member that holds the ID of the hosting stream</p> </li>
<li id="GUID-8AE6849E-0BA8-5CB4-8F3F-B33CC4FEED4E"><p><codeph>iEmbeddedStore</codeph> holds
a reference to the embedded store object.</p> </li>
</ul>
<p>When saving data, an application re-creates the embedded store by re-writing
the complete partial object network to the embedded store, replacing any existing
data.</p>
</conbody></concept>