|
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 // |
|
15 |
|
16 #ifndef __D32REC_H__ |
|
17 #define __D32REC_H__ |
|
18 #ifndef __E32BASE_H__ |
|
19 #include <e32base.h> |
|
20 #endif |
|
21 #ifndef __D32DBMS_H__ |
|
22 #include <d32dbms.h> |
|
23 #endif |
|
24 #ifndef __D32DBAS__ |
|
25 #include "D32DBAS.H" |
|
26 #endif |
|
27 |
|
28 // classes used in this header |
|
29 class RDbTableRow; |
|
30 class MStreamBuf; |
|
31 |
|
32 // classes defined in this header |
|
33 class TDbRecordId; |
|
34 class CDbRecordBase; |
|
35 class CDbRecordIter; |
|
36 class CDbRecordSpace; |
|
37 class CDbBlobSpace; |
|
38 class CDbRecordIndex; |
|
39 |
|
40 /** |
|
41 @internalComponent |
|
42 */ |
|
43 enum TDbPosition { EDbFirst=RDbRowSet::EFirst,EDbNext=RDbRowSet::ENext,EDbPrevious=RDbRowSet::EPrevious,EDbLast=RDbRowSet::ELast }; |
|
44 |
|
45 /** |
|
46 @internalComponent |
|
47 */ |
|
48 const TUint32 KDbNullRecordIdValue=0; |
|
49 class TDbRecordId |
|
50 /** |
|
51 @internalComponent |
|
52 */ |
|
53 { |
|
54 public: |
|
55 TDbRecordId() {} |
|
56 inline TDbRecordId(TUint32 aValue); |
|
57 inline TDbRecordId& operator=(TUint32 aValue); |
|
58 // |
|
59 inline TBool operator==(TDbRecordId anId) const; |
|
60 inline TBool operator!=(TDbRecordId anId) const; |
|
61 // |
|
62 inline TUint32 Value() const; |
|
63 private: |
|
64 TUint32 iValue; |
|
65 }; |
|
66 #if defined(__NO_CLASS_CONSTS__) |
|
67 /** |
|
68 @internalComponent |
|
69 */ |
|
70 #define KDbNullRecordId TDbRecordId(KDbNullRecordIdValue) |
|
71 #else |
|
72 /** |
|
73 @internalComponent |
|
74 */ |
|
75 const TDbRecordId KDbNullRecordId=TDbRecordId(KDbNullRecordIdValue); |
|
76 #endif |
|
77 |
|
78 class CDbRecordBase : public CBase |
|
79 /** |
|
80 @internalComponent |
|
81 */ |
|
82 { |
|
83 private: |
|
84 enum {EOpen=0x1,EModified=0x2,EBroken=0x4}; |
|
85 protected: |
|
86 CDbRecordBase() {} |
|
87 public: |
|
88 inline TBool OpenL(); |
|
89 IMPORT_C void FlushL(); |
|
90 inline void Abandon(); |
|
91 inline TBool IsBroken() const; |
|
92 // |
|
93 static void DoFlushL(CDbRecordBase* aRec); |
|
94 static void DoDelete(CDbRecordBase* aRec); |
|
95 static void DoAbandon(CDbRecordBase* aRec); |
|
96 protected: |
|
97 IMPORT_C void TouchL(); |
|
98 inline void MarkIntact(); |
|
99 private: |
|
100 IMPORT_C TBool DoRestoreL(); |
|
101 IMPORT_C virtual TBool RestoreL(); |
|
102 IMPORT_C virtual void AboutToModifyL(); |
|
103 IMPORT_C virtual void SynchL(); |
|
104 private: |
|
105 TUint iFlags; |
|
106 }; |
|
107 |
|
108 class CDbRecordIter : public CBase |
|
109 /** |
|
110 @internalComponent |
|
111 */ |
|
112 { |
|
113 public: |
|
114 enum TDeleted {EAtRow,ENoRow,ENotSupported}; |
|
115 protected: |
|
116 IMPORT_C CDbRecordIter(CDbRecordBase& aHost); |
|
117 public: |
|
118 IMPORT_C ~CDbRecordIter(); |
|
119 inline CDbRecordBase& Host() const; |
|
120 // pure virtual |
|
121 virtual TInt Count() const =0; |
|
122 virtual TDbRecordId CurrentL() =0; |
|
123 virtual TBool GotoL(TDbPosition aPosition) =0; |
|
124 virtual TBool GotoL(TDbRecordId aRecordId,RDbTableRow& aBuffer) =0; // re-synchronise |
|
125 virtual TBool SeekL(const TDbLookupKey& aKey,RDbTable::TComparison aComparison) =0; |
|
126 inline TDeleted DeletedL(TDbPosition aPosition,TDbRecordId aRecordId); // goto next id |
|
127 inline TDeleted DeletedL(TDbPosition aPosition,TDbRecordId aRecordId,const RDbTableRow& aRow); // goto next id |
|
128 // |
|
129 virtual TDeleted DoDeletedL(TDbPosition aPosition,TDbRecordId aRecordId,const RDbTableRow* aRow) =0; |
|
130 private: |
|
131 CDbRecordBase& iHost; |
|
132 }; |
|
133 |
|
134 class CDbRecordSpace : public CDbRecordBase |
|
135 /** |
|
136 @internalComponent |
|
137 */ |
|
138 { |
|
139 protected: |
|
140 CDbRecordSpace() {} |
|
141 public: |
|
142 virtual TBool ExistsL(TDbRecordId aRecordId) =0; |
|
143 virtual TPtrC8 ReadL(TDbRecordId aRecordId) const =0; |
|
144 TUint8* ReplaceL(TDbRecordId aRecordId,TInt aRecordSize); |
|
145 virtual TUint AutoIncrementL() =0; |
|
146 TUint8* NewL(TInt aRecordSize); |
|
147 virtual TDbRecordId AppendL() =0; |
|
148 void EraseL(TDbRecordId aRecordId); |
|
149 virtual CDbRecordIter* IteratorL() =0; |
|
150 private: |
|
151 virtual TUint8* DoReplaceL(TDbRecordId aRecordId,TInt aRecordSize) =0; |
|
152 virtual TUint8* DoNewL(TInt aRecordSize) =0; |
|
153 virtual void DoEraseL(TDbRecordId aRecordId) =0; |
|
154 }; |
|
155 |
|
156 class CDbBlobSpace : public CDbRecordBase |
|
157 /** |
|
158 @internalComponent |
|
159 */ |
|
160 { |
|
161 protected: |
|
162 CDbBlobSpace() {} |
|
163 public: |
|
164 virtual MStreamBuf* ReadL(TDbBlobId aBlobId,TDbColType aType) const =0; |
|
165 IMPORT_C MStreamBuf* ReadLC(TDbBlobId aBlobId,TDbColType aType) const; |
|
166 IMPORT_C MStreamBuf* CreateL(TDbBlobId &aBlobId,TDbColType aType); |
|
167 IMPORT_C TDbBlobId CreateL(TDbColType aType,const TAny* aBuf,TInt aLength); |
|
168 IMPORT_C void DeleteL(TDbBlobId aBlobId); |
|
169 IMPORT_C TInt Delete(TDbBlobId aBlobId); |
|
170 inline TInt InlineLimit() const; |
|
171 protected: |
|
172 inline void SetInlineLimit(TInt anInlineLimit); |
|
173 private: |
|
174 virtual MStreamBuf* DoCreateL(TDbBlobId &aBlobId,TDbColType aType) =0; |
|
175 virtual void DoDeleteL(TDbBlobId aBlobId) =0; |
|
176 private: |
|
177 TInt iInlineLimit; |
|
178 }; |
|
179 |
|
180 class CDbRecordIndex : public CDbRecordBase |
|
181 /** |
|
182 @internalComponent |
|
183 */ |
|
184 { |
|
185 public: |
|
186 enum TFind {ENoMatch,EKeyMatch,EEntryMatch}; |
|
187 enum TInclusion {EIncludeLower=0x1,EIncludeUpper=0x2,EIncludeBoth=0x3}; |
|
188 protected: |
|
189 CDbRecordIndex() {} |
|
190 public: |
|
191 virtual TFind FindL(TDbRecordId aRecordId,const RDbTableRow& aRow) =0; |
|
192 TBool InsertL(TDbRecordId aRecordId,const RDbTableRow& aRow); |
|
193 void DeleteL(TDbRecordId aRecordId,const RDbTableRow& aRow); |
|
194 virtual CDbRecordIter* IteratorL(TUint aInclusion=0,const TDbLookupKey* aLowerBound=0,const TDbLookupKey* aUpperBound=0) =0; |
|
195 private: |
|
196 virtual TBool DoInsertL(TDbRecordId aRecordId,const RDbTableRow& aRow) =0; |
|
197 virtual void DoDeleteL(TDbRecordId aRecordId,const RDbTableRow& aRow) =0; |
|
198 }; |
|
199 |
|
200 #include "D32REC.INL" |
|
201 #endif |