Symbian3/SDK/Source/GUID-AA5DEEB2-0B13-5FA8-8494-EC2F5C654FEF.dita
author Dominic Pinkman <Dominic.Pinkman@Nokia.com>
Wed, 31 Mar 2010 11:11:55 +0100
changeset 7 51a74ef9ed63
child 13 48780e181b38
permissions -rw-r--r--
Week 12 contribution of API Specs and fix SDK submission

<?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-AA5DEEB2-0B13-5FA8-8494-EC2F5C654FEF" xml:lang="en"><title>CentRepExample:
Using Central Repository for Persistent Storage</title><shortdesc>This example application demonstrates the usage of Central Repository
API for persistent storage.</shortdesc><prolog><metadata><keywords/></metadata></prolog><conbody>
<section id="GUID-E2129D18-6FBB-55B9-8D79-420EB2CF2401"><title>Description</title> <p>Several
Symbian platform components have state and settings information that need
to be persistent. There is also a global state that needs to persist, for
example, default filenames, locale settings, user preferences. </p> <p>The
CentRep example application first registers a group of settings with the central
repository server. It uses <filepath>E80000AD.txt</filepath>, a UTF-16 format
text file to initialise the repository. This text file contains access control
structure and the initial content of the repository. It is recommended to
convert the initialisation text file into a binary file using the central
repository converter tool to speed up the execution. </p> <p>The application
creates a <xref href="GUID-DEA618DF-D462-3B3E-A1E1-F21295AAFE78.dita"><apiname>CRepository</apiname></xref> object using the <xref href="GUID-DEA618DF-D462-3B3E-A1E1-F21295AAFE78.dita#GUID-DEA618DF-D462-3B3E-A1E1-F21295AAFE78/GUID-B8DD1F6F-5A03-30C7-A5B5-51053D9FBDD3"><apiname>CRepository::NewLC()</apiname></xref> method
to access a repository using its UID. It resets the whole repository using <xref href="GUID-DEA618DF-D462-3B3E-A1E1-F21295AAFE78.dita#GUID-DEA618DF-D462-3B3E-A1E1-F21295AAFE78/GUID-BA806B9D-C347-3722-886E-1290A4A0618A"><apiname>CRepository::Reset()</apiname></xref> method
with the contents in the initialisation file. </p> <p>Each setting stored
in the repository will have a unique key to identify the setting. This unique
key is used to read and change the setting by calling the <xref href="GUID-DEA618DF-D462-3B3E-A1E1-F21295AAFE78.dita#GUID-DEA618DF-D462-3B3E-A1E1-F21295AAFE78/GUID-AB3918A5-BA69-3EE8-89B4-51DD8A899AF5"><apiname>CRepository::Get()</apiname></xref> and <xref href="GUID-DEA618DF-D462-3B3E-A1E1-F21295AAFE78.dita#GUID-DEA618DF-D462-3B3E-A1E1-F21295AAFE78/GUID-114079A1-A8CA-3FE7-8FAD-F5E61453FF6B"><apiname>CRepository::Set()</apiname></xref> methods
respectively. The application moves these keys to a different location using <xref href="GUID-DEA618DF-D462-3B3E-A1E1-F21295AAFE78.dita#GUID-DEA618DF-D462-3B3E-A1E1-F21295AAFE78/GUID-4F005B5F-2664-3F7C-848D-B6F93462F2F4"><apiname>CRepository::Move()</apiname></xref> method
and deletes them from their original location. </p> <p>The application also
creates another <codeph>CRepository</codeph> object to demonstrate that, at
any given point a repository cannot be opened with <i>READ/WRITE</i> access
by more than one client. In such situations, it is recommended to start a
transaction before a write operation using <xref href="GUID-DEA618DF-D462-3B3E-A1E1-F21295AAFE78.dita#GUID-DEA618DF-D462-3B3E-A1E1-F21295AAFE78/GUID-1F14EB0C-89CF-3A76-A678-5F6F86F50B32"><apiname>CRepository::StartTransaction()</apiname></xref> method.
A transaction guarantees the consistency and persistence of all values read
and written during the transaction. </p> <p>Finally, the application requests
the central repository server to notify any changes to the original settings. </p><p><b>Related
APIs</b></p><ul>
<li><p><xref href="GUID-DEA618DF-D462-3B3E-A1E1-F21295AAFE78.dita"><apiname>CRepository</apiname></xref> - Provides access to a repository.</p></li>
<li><p><xref href="GUID-DEA618DF-D462-3B3E-A1E1-F21295AAFE78.dita#GUID-DEA618DF-D462-3B3E-A1E1-F21295AAFE78/GUID-AB3918A5-BA69-3EE8-89B4-51DD8A899AF5"><apiname>CRepository::Get()</apiname></xref></p></li>
<li><p><xref href="GUID-DEA618DF-D462-3B3E-A1E1-F21295AAFE78.dita#GUID-DEA618DF-D462-3B3E-A1E1-F21295AAFE78/GUID-4F005B5F-2664-3F7C-848D-B6F93462F2F4"><apiname>CRepository::Move()</apiname></xref></p></li>
<li><p><xref href="GUID-DEA618DF-D462-3B3E-A1E1-F21295AAFE78.dita#GUID-DEA618DF-D462-3B3E-A1E1-F21295AAFE78/GUID-B8DD1F6F-5A03-30C7-A5B5-51053D9FBDD3"><apiname>CRepository::NewLC()</apiname></xref></p></li>
<li><p><xref href="GUID-DEA618DF-D462-3B3E-A1E1-F21295AAFE78.dita#GUID-DEA618DF-D462-3B3E-A1E1-F21295AAFE78/GUID-BA806B9D-C347-3722-886E-1290A4A0618A"><apiname>CRepository::Reset()</apiname></xref></p></li>
<li><p><xref href="GUID-DEA618DF-D462-3B3E-A1E1-F21295AAFE78.dita#GUID-DEA618DF-D462-3B3E-A1E1-F21295AAFE78/GUID-114079A1-A8CA-3FE7-8FAD-F5E61453FF6B"><apiname>CRepository::Set()</apiname></xref></p></li>
<li><p><xref href="GUID-DEA618DF-D462-3B3E-A1E1-F21295AAFE78.dita#GUID-DEA618DF-D462-3B3E-A1E1-F21295AAFE78/GUID-1F14EB0C-89CF-3A76-A678-5F6F86F50B32"><apiname>CRepository::StartTransaction()</apiname></xref></p></li>
</ul> </section>
<section id="GUID-3B353EAA-5FE4-426B-A0A5-6800CE0BC9E3"><title>Download</title> <p>Click
on the following link to download the example: <xref href="guid-6013a680-57f9-415b-8851-c4fa63356636/zips/guid-e78b3d2c-7205-45ca-abe0-163e33a0fcc3.zip" scope="external">CentRepExample.zip</xref></p><p>Click: <xref href="guid-6013a680-57f9-415b-8851-c4fa63356636/guid-e78b3d2c-7205-45ca-abe0-163e33a0fcc3.html" scope="peer">browse</xref> to view the example code.</p> </section>
<section id="GUID-DCCBE8DE-0BBD-5528-A460-E1645116DD4F"><title>Build</title> <p>The <xref href="GUID-3100800B-B2F7-50EF-BD4C-3C345ECCB2A5.dita">Symbian build process</xref> describes
how to build an application. </p> <p>The <codeph>CentRepExample</codeph> builds
an executable called <filepath>CentRepExample.exe</filepath> in the standard
location (\epoc32\release\winscw\&lt;<i>build_variant</i> &gt; for CodeWarrior).
After launching the executable, depending on the emulator you are using, you
may need to task away from the app launcher/shell screen to view the console. </p> </section>
</conbody></concept>