|
1 // Copyright (c) 1998-2009 Nokia Corporation and/or its subsidiary(-ies). |
|
2 // All rights reserved. |
|
3 // This component and the accompanying materials are made available |
|
4 // under the terms of "Eclipse Public License v1.0" |
|
5 // which accompanies this distribution, and is available |
|
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
7 // |
|
8 // Initial Contributors: |
|
9 // Nokia Corporation - initial contribution. |
|
10 // |
|
11 // Contributors: |
|
12 // |
|
13 // Description: |
|
14 // The Store-Database |
|
15 // |
|
16 // |
|
17 |
|
18 #ifndef __D32STOR_H__ |
|
19 #define __D32STOR_H__ |
|
20 #ifndef __D32TABLE_H__ |
|
21 #include "D32TABLE.H" |
|
22 #endif |
|
23 #ifndef __S32STOR_H__ |
|
24 #include <s32stor.h> |
|
25 #endif |
|
26 |
|
27 // other classes referenced |
|
28 class MDbStreamFilter; |
|
29 class CDbStoreCompression; |
|
30 class CClusterCache; |
|
31 |
|
32 // classes defined |
|
33 class CDbStoreDatabase; |
|
34 class CDbFileStoreDatabase; |
|
35 |
|
36 /** |
|
37 @internalComponent |
|
38 */ |
|
39 enum TDbStoreVersion { EDbStoreVersion2=3,EDbStoreSecure,EDbStoreCompressed }; |
|
40 |
|
41 /** |
|
42 @internalComponent |
|
43 */ |
|
44 class CDbStoreDatabase : public CDbTableDatabase |
|
45 { |
|
46 public: |
|
47 enum TZipType {EDeflate,EInflate}; |
|
48 |
|
49 private: |
|
50 #ifndef PAGE_CACHE_SIZE |
|
51 #define PAGE_CACHE_SIZE 16 |
|
52 #else |
|
53 #if PAGE_CACHE_SIZE < 8 |
|
54 #error "PAGE_CACHE_SIZE macro value can't be less than 8" |
|
55 #endif |
|
56 #endif |
|
57 enum {EPageCachePages=PAGE_CACHE_SIZE}; |
|
58 enum {EModified=0x1,EDamaged=0x2,ESharedStore=0x80000000}; |
|
59 class CCompactor; |
|
60 |
|
61 public: |
|
62 // factory functions for pure StoreDatabase |
|
63 static CDbDatabase* CreateL(CStreamStore* aStore,TStreamId& aStreamId); |
|
64 static CDbSource* OpenL(CStreamStore* aStore,TStreamId aStreamId); |
|
65 static void CompressL(CStreamStore* aStore,TStreamId aStreamId,TZipType aZip); |
|
66 // accessors |
|
67 inline CStreamStore& Store(); |
|
68 inline MDbStreamFilter* Filter(); |
|
69 CClusterCache& ClusterCacheL(); |
|
70 MPagePool& PagePoolL(); |
|
71 // user-class's transaction protocol |
|
72 void MarkL(); |
|
73 void IndexRecoveredL(); |
|
74 |
|
75 protected: |
|
76 IMPORT_C CDbStoreDatabase(); |
|
77 IMPORT_C ~CDbStoreDatabase(); |
|
78 // phase 2 c'tors |
|
79 IMPORT_C TStreamId ConstructL(); |
|
80 // framework: authentication |
|
81 IMPORT_C void AuthenticateL(); |
|
82 IMPORT_C void RestoreL(TStreamId aStreamId); |
|
83 // framework: pure delegated functions |
|
84 IMPORT_C TInt Property(CDbDatabase::TProperty aProperty); |
|
85 IMPORT_C void DestroyL(); |
|
86 // framework: transaction protocol |
|
87 IMPORT_C void LoadSchemaL(); |
|
88 IMPORT_C void SynchL(TDbLockType aLock); |
|
89 IMPORT_C void Revert(TDbLockType aLock); |
|
90 IMPORT_C void Idle(); |
|
91 // framework: object factory |
|
92 IMPORT_C CDbTableDef* CreateTableL(const TDesC& aName,const CDbColSet& aColSet,const CDbKey* aPrimaryKey); |
|
93 IMPORT_C CDbTableIndexDef* CreateIndexL(const CDbTableDef& aTable,const TDesC& aName,const CDbKey& aKey); |
|
94 IMPORT_C CDbTable* TableL(const CDbTableDef& aDef); |
|
95 // framework: incremental factory |
|
96 IMPORT_C CStepper* TableAlterL(CDbTableDef& aTable,const HDbColumnSet& aNewSet,TInt& aStep); |
|
97 IMPORT_C CStepper* RecordDiscarderL(const CDbTableDef& aTable,TInt& aStep); |
|
98 IMPORT_C CStepper* IndexDiscarderL(const CDbTableDef& aTable,const CDbTableIndexDef& anIndex,TInt& aStep); |
|
99 IMPORT_C CStepper* UtilityL(CDbDatabase::TUtility aType,TInt& aStep); |
|
100 |
|
101 private: |
|
102 // framework: reserved |
|
103 IMPORT_C void Reserved_1(); |
|
104 IMPORT_C void Reserved_2(); |
|
105 // implementationp functions |
|
106 static CDbStoreDatabase* NewLC(CStreamStore* aStore); |
|
107 // |
|
108 void CompressTablesL(); |
|
109 void CompressL(TStreamId aStreamId,TZipType aZip); |
|
110 // |
|
111 void ReadHeaderL(RReadStream& aStream); |
|
112 void InitPagePoolL(); |
|
113 void ReplaceSchemaL(); |
|
114 void ReplaceTokenL(TUint aFlags); |
|
115 void SynchStoreL(TDbLockType aLock); |
|
116 CDbStoreCompression& CompressionL(); |
|
117 CStepper* RecoverL(TInt& aStep); |
|
118 |
|
119 protected: |
|
120 CStreamStore* iStore; |
|
121 TInt iReclaim; |
|
122 |
|
123 private: |
|
124 TUint8 iVersion; |
|
125 TUint8 iFlags; |
|
126 TUint8 iSharedStore; |
|
127 TStreamId iSchemaId; |
|
128 TStreamId iTokenId; |
|
129 TStorePagePoolToken iPoolToken; |
|
130 RStorePagePool* iPagePool; |
|
131 CPageCache* iPageCache; |
|
132 CClusterCache* iClusterCache; |
|
133 MDbStreamFilter* iFilter; |
|
134 CDbStoreCompression* iCompression; |
|
135 |
|
136 }; |
|
137 |
|
138 /** |
|
139 The general file-store database class |
|
140 @internalComponent |
|
141 */ |
|
142 const TInt32 KDbmsFileDatabaseUidValue=0x10000EBE; |
|
143 const TUid KDbmsFileDatabaseUid={KDbmsFileDatabaseUidValue}; |
|
144 |
|
145 /** |
|
146 @internalComponent |
|
147 */ |
|
148 class CDbFileStoreDatabase : public CDbStoreDatabase |
|
149 { |
|
150 public: |
|
151 IMPORT_C static CDbDatabase* CreateL(RFs& aFs, const TDesC& aName, TDbFormat::TCreate aMode, |
|
152 const TUidType& aType); |
|
153 IMPORT_C static CDbSource* OpenL(RFs& aFs,const TDesC& aName,TDbFormat::TOpen aMode); |
|
154 |
|
155 protected: |
|
156 IMPORT_C CDbFileStoreDatabase(RFs& aFs); |
|
157 IMPORT_C ~CDbFileStoreDatabase(); |
|
158 // |
|
159 IMPORT_C void CreateL(const TDesC& aName, TDbFormat::TCreate aMode, const TUidType& aType); |
|
160 IMPORT_C virtual TStreamId CreateRootL(TStreamId aDatabaseId); |
|
161 // |
|
162 IMPORT_C void OpenL(const TDesC& aName,TDbFormat::TOpen aMode); |
|
163 IMPORT_C virtual TStreamId DatabaseIdL(TStreamId aRootId); |
|
164 // from CDbStoreDatabase |
|
165 IMPORT_C TInt Property(CDbDatabase::TProperty aProperty); |
|
166 IMPORT_C void DestroyL(); |
|
167 |
|
168 private: |
|
169 static CDbFileStoreDatabase* NewLC(RFs& aFs); |
|
170 |
|
171 private: |
|
172 RFs& iFs; |
|
173 HBufC* iName; |
|
174 TBool iDelete; |
|
175 |
|
176 }; |
|
177 |
|
178 #endif |