Symbian3/SDK/Source/GUID-95448841-5E5B-54C4-85A7-DCE6D078E036.dita
author Dominic Pinkman <Dominic.Pinkman@Nokia.com>
Thu, 21 Jan 2010 18:18:20 +0000
changeset 0 89d6a7a84779
permissions -rw-r--r--
Initial contribution of Documentation_content according to Feature bug 1266 bug 1268 bug 1269 bug 1270 bug 1372 bug 1374 bug 1375 bug 1379 bug 1380 bug 1381 bug 1382 bug 1383 bug 1385

<?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-95448841-5E5B-54C4-85A7-DCE6D078E036"><title>Constructing an embedded store</title><prolog><metadata><keywords/></metadata></prolog><conbody><p>Embedded stores are represented by an instance of the <codeph>CEmbeddedStore</codeph> class.</p> <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>