Symbian3/SDK/Source/GUID-B683496C-652E-5F48-924E-52D2FF3A78A7.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-B683496C-652E-5F48-924E-52D2FF3A78A7" xml:lang="en"><title>Direct
       
    13 File Store</title><shortdesc>The main characteristic of a direct file store is that streams
       
    14 can be created and objects externalized to them but, once the streams have
       
    15 been committed and closed, they cannot subsequently be changed.</shortdesc><prolog><metadata><keywords/></metadata></prolog><conbody>
       
    16 <p>Once the streams have been committed and closed, they cannot be replaced,
       
    17 deleted, extended or changed in any way. A direct file store is useful for
       
    18 the type of application which treats the in-memory copy of its data as its
       
    19 prime copy, such as a word processor which implements the classic load/save
       
    20 paradigm. In this paradigm:</p>
       
    21 <ul>
       
    22 <li id="GUID-DE651688-71D8-5E52-BA3A-D3ED93B58F55"><p>application data is
       
    23 first created, in an internal, non-persistent, form — i.e., in RAM</p> </li>
       
    24 <li id="GUID-F6012000-CE82-5940-9CEB-386664FF0EA5"><p>when the file is first
       
    25 saved, the data is externalised to the file store. When saving its data, an
       
    26 application writes the whole object network forming the data to a new direct
       
    27 file store, replacing any existing file of the same name. The last stream
       
    28 written is always the root stream.</p> </li>
       
    29 <li id="GUID-9896F0DD-1D96-5EC7-959F-D3C7EB226BD6"><p>the application can
       
    30 exit</p> </li>
       
    31 <li id="GUID-27B6B647-FA91-52BF-855C-2F6CE31AB0E6"><p>when the application
       
    32 is started again, it can open the file store and read in the persistent data.
       
    33 It need not load the whole object network into memory; the loading of objects
       
    34 can be deferred by using Swizzles. </p> </li>
       
    35 <li id="GUID-1BF73B14-8CB1-57B3-A687-7C76B5100C9E"><p>the data is edited in
       
    36 its internal, non-persistent form</p> </li>
       
    37 <li id="GUID-8FFA6658-0753-5601-979A-2833AD415691"><p>when data is saved again,
       
    38 the old file is erased (or renamed for safety!) and completely rewritten</p> </li>
       
    39 </ul>
       
    40 <p>With a direct file store, a stream may not be appended once it has been
       
    41 written and closed. Writing to different streams may not be interleaved. The
       
    42 root stream must be the last stream to be written. The direct file store is
       
    43 very efficient as the allocation of new streams, and finding existing streams,
       
    44 are trivially mapped onto the most efficient operations of the underlying
       
    45 file system.</p>
       
    46 <p>For this type of application, the most efficient file format is obtained
       
    47 when all the data is written in sequence to the file. Any references within
       
    48 the file are to data which was written earlier. When reading the file back,
       
    49 it is read in several sections starting with a section that is at the <i>end</i> of
       
    50 the file.</p>
       
    51 <p>A typical relationship between a direct file store and its contained streams
       
    52 is shown below. In this stream network streams <i>I</i> and <i>J</i> must
       
    53 be written before stream <i>A</i>; stream <i>K</i> must be written before
       
    54 stream <i>C</i>; streams <i>A</i>,<i>B</i> and <i>C</i> must be written before
       
    55 the root stream.</p>
       
    56 <fig id="GUID-D45A96E3-5900-5817-8B32-8AA74E3DE584">
       
    57 <title>Streams linked in a store</title>
       
    58 <image href="GUID-DE5FC074-75C1-5833-83B2-D25396F52732_d0e360725_href.png" placement="inline"/>
       
    59 </fig>
       
    60 <p>Direct file stores are encapsulated by the <codeph>CDirectFileStore</codeph> class. </p>
       
    61 </conbody><related-links>
       
    62 <link href="GUID-D7211372-9411-5A18-88F0-615F4983A2E0.dita"><linktext>Store Streams</linktext>
       
    63 </link>
       
    64 </related-links></concept>