williamr@4
|
1 |
// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
|
williamr@4
|
2 |
// All rights reserved.
|
williamr@4
|
3 |
// This component and the accompanying materials are made available
|
williamr@4
|
4 |
// under the terms of "Eclipse Public License v1.0"
|
williamr@4
|
5 |
// which accompanies this distribution, and is available
|
williamr@4
|
6 |
// at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
williamr@4
|
7 |
//
|
williamr@4
|
8 |
// Initial Contributors:
|
williamr@4
|
9 |
// Nokia Corporation - initial contribution.
|
williamr@4
|
10 |
//
|
williamr@4
|
11 |
// Contributors:
|
williamr@4
|
12 |
//
|
williamr@4
|
13 |
// Description:
|
williamr@4
|
14 |
//
|
williamr@4
|
15 |
|
williamr@4
|
16 |
#if !defined(__DIRECTFILESTORE_H__)
|
williamr@4
|
17 |
#define __DIRECTFILESTORE_H__
|
williamr@4
|
18 |
|
williamr@4
|
19 |
#include <pcstore/pcstoredef.h>
|
williamr@4
|
20 |
#include <pcstore/streamid.h>
|
williamr@4
|
21 |
#include <pcstore/uid.h>
|
williamr@4
|
22 |
|
williamr@4
|
23 |
namespace PCStore
|
williamr@4
|
24 |
{
|
williamr@4
|
25 |
class TUidType;
|
williamr@4
|
26 |
class CStoreWriteStream;
|
williamr@4
|
27 |
class CStoreReadStream;
|
williamr@4
|
28 |
class CFileStreamBuf;
|
williamr@4
|
29 |
|
williamr@4
|
30 |
const TInt KDirectFileStoreLayoutUidValue=0x10000037; //268435511;
|
williamr@4
|
31 |
const TUid KDirectFileStoreLayoutUid={KDirectFileStoreLayoutUidValue};
|
williamr@4
|
32 |
|
williamr@4
|
33 |
/**
|
williamr@4
|
34 |
@internalAll
|
williamr@4
|
35 |
|
williamr@4
|
36 |
Direct file store.
|
williamr@4
|
37 |
|
williamr@4
|
38 |
A direct file store implements a set of the operations to open store, create streams(CStoreWriteStream
|
williamr@4
|
39 |
and CStoreReadStream), set root stream id to the store.
|
williamr@4
|
40 |
|
williamr@4
|
41 |
Objects can be externalized to streams represented by class CStoreWriteStream. Once the streams
|
williamr@4
|
42 |
have been closed, they cannot subsequently be changed, i.e. streams cannot be replaced, deleted,
|
williamr@4
|
43 |
extended or changed in any way.
|
williamr@4
|
44 |
|
williamr@4
|
45 |
Existing direct file stores can be opened with this class. Objects can be restored with class
|
williamr@4
|
46 |
CStoreReadStream.
|
williamr@4
|
47 |
|
williamr@4
|
48 |
Before closing a new store, the root stream id must be set. After opening an existing store, the
|
williamr@4
|
49 |
first thing done is to look up the root stream id. The root stream can then be opened and data
|
williamr@4
|
50 |
read from the store.
|
williamr@4
|
51 |
|
williamr@4
|
52 |
@see CStoreWriteStream
|
williamr@4
|
53 |
@see CStoreReadStream
|
williamr@4
|
54 |
*/
|
williamr@4
|
55 |
class CDirectFileStore
|
williamr@4
|
56 |
{
|
williamr@4
|
57 |
public:
|
williamr@4
|
58 |
//Enumerations for the store open mode
|
williamr@4
|
59 |
enum TStoreMode
|
williamr@4
|
60 |
{
|
williamr@4
|
61 |
EReadStore=0,
|
williamr@4
|
62 |
EWriteStore=1
|
williamr@4
|
63 |
};
|
williamr@4
|
64 |
|
williamr@4
|
65 |
public:
|
williamr@4
|
66 |
~CDirectFileStore();
|
williamr@4
|
67 |
|
williamr@4
|
68 |
void SetRoot(TStreamId aId);
|
williamr@4
|
69 |
TStreamId Root() const;
|
williamr@4
|
70 |
static CDirectFileStore* Open(const char* aFileName);
|
williamr@4
|
71 |
static CDirectFileStore* Replace(const char* aFileName);
|
williamr@4
|
72 |
static CDirectFileStore* Replace(const char* aFileName, const TUidType& aType);
|
williamr@4
|
73 |
CStoreWriteStream* CreateWriteStream(TStreamId& aId);
|
williamr@4
|
74 |
CStoreReadStream* CreateReadStream(TStreamId aId);
|
williamr@4
|
75 |
|
williamr@4
|
76 |
private:
|
williamr@4
|
77 |
CDirectFileStore(const char* aFileName, TStoreMode aMode);
|
williamr@4
|
78 |
CStoreWriteStream* CreateIdWriteStream(TStreamId aId);
|
williamr@4
|
79 |
|
williamr@4
|
80 |
void SetType(const TUidType& aType);
|
williamr@4
|
81 |
void CheckType();
|
williamr@4
|
82 |
void Externalize(CStoreWriteStream& aWs) const;
|
williamr@4
|
83 |
void Internalize(CStoreReadStream& aRs);
|
williamr@4
|
84 |
|
williamr@4
|
85 |
private:
|
williamr@4
|
86 |
TStoreMode iMode;
|
williamr@4
|
87 |
TStreamId iRoot;
|
williamr@4
|
88 |
CFileStreamBuf* iFileStreamBuf;
|
williamr@4
|
89 |
};
|
williamr@4
|
90 |
}
|
williamr@4
|
91 |
#endif // !defined(__DIRECTFILESTORE_H__)
|