|
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 #if !defined(__S32CONT_H__) |
|
17 #define __S32CONT_H__ |
|
18 #if !defined(__S32BTREE_H__) |
|
19 #include <s32btree.h> |
|
20 #endif |
|
21 |
|
22 /** |
|
23 * @publishedAll |
|
24 * @released |
|
25 */ |
|
26 class TPagedSetToken : public TBtreeToken |
|
27 { |
|
28 public: |
|
29 TPagedSetToken() {} |
|
30 inline TPagedSetToken(TEmpty); |
|
31 // |
|
32 inline TInt Count() const; |
|
33 // |
|
34 IMPORT_C void ExternalizeL(RWriteStream& aStream) const; |
|
35 IMPORT_C void InternalizeL(RReadStream& aStream); |
|
36 protected: |
|
37 IMPORT_C void Clear(); |
|
38 private: |
|
39 inline TPagedSetToken(const TBtreeToken& aTree,TInt aCount); |
|
40 private: |
|
41 TInt iCount; |
|
42 private: |
|
43 friend class TPagedSetBase; |
|
44 }; |
|
45 #define KEmptyPagedSetToken TPagedSetToken(TPagedSetToken::EEmpty) |
|
46 |
|
47 /** |
|
48 * @publishedAll |
|
49 * @released |
|
50 */ |
|
51 class TPagedSetBase |
|
52 { |
|
53 public: |
|
54 IMPORT_C void Connect(MPagePool* aPool); |
|
55 IMPORT_C void Set(const TPagedSetToken& aToken); |
|
56 IMPORT_C TPagedSetToken Token() const; |
|
57 // |
|
58 inline TBool IsDirty() const; |
|
59 inline void MarkCurrent(); |
|
60 inline void MarkDirty(); |
|
61 // |
|
62 inline TBool IsBroken() const; |
|
63 inline TBool IsIntact() const; |
|
64 inline void MarkBroken(); |
|
65 IMPORT_C TInt RepairL(); |
|
66 // |
|
67 inline TInt Count() const; |
|
68 inline TBool IsEmpty() const; |
|
69 IMPORT_C void ClearL(); |
|
70 // |
|
71 IMPORT_C TBool ContainsL(const TAny* aPtr) const; |
|
72 IMPORT_C void InsertL(const TAny* aPtr); |
|
73 IMPORT_C void DeleteL(const TAny* aPtr); |
|
74 protected: |
|
75 IMPORT_C TPagedSetBase(TInt anEntrySize); |
|
76 IMPORT_C TPagedSetBase(const TPagedSetToken& aToken,TInt anEntrySize); |
|
77 IMPORT_C void InsertAllowDuplicatesL(const TAny* aPtr); |
|
78 private: |
|
79 TBtreeFix<TAny,TAny> iTree; |
|
80 TBtreeKey iKey; |
|
81 TInt iCount; |
|
82 private: |
|
83 friend class TPagedSetIterBase; |
|
84 friend class TPagedSetBiIterBase; |
|
85 }; |
|
86 |
|
87 /** |
|
88 * @publishedAll |
|
89 * @released |
|
90 */ |
|
91 class TPagedMultisetBase : public TPagedSetBase |
|
92 { |
|
93 public: |
|
94 inline void InsertL(const TAny* aPtr); |
|
95 protected: |
|
96 inline TPagedMultisetBase(TInt anEntrySize); |
|
97 inline TPagedMultisetBase(const TPagedSetToken& aToken,TInt anEntrySize); |
|
98 }; |
|
99 |
|
100 /** |
|
101 * @publishedAll |
|
102 * @released |
|
103 */ |
|
104 template <class T> |
|
105 class TPagedSet : public TPagedSetBase |
|
106 { |
|
107 public: |
|
108 inline TPagedSet(); |
|
109 inline TPagedSet(const TPagedSetToken& aToken); |
|
110 // |
|
111 inline TBool ContainsL(const T& anObject) const; |
|
112 inline void InsertL(const T& anObject); |
|
113 inline void DeleteL(const T& anObject); |
|
114 }; |
|
115 |
|
116 /** |
|
117 * @publishedAll |
|
118 * @released |
|
119 */ |
|
120 TEMPLATE_SPECIALIZATION class TPagedSet<TAny> : public TPagedSetBase |
|
121 { |
|
122 public: |
|
123 inline TPagedSet(TInt anEntrySize); |
|
124 inline TPagedSet(const TPagedSetToken& aToken,TInt anEntrySize); |
|
125 }; |
|
126 |
|
127 /** |
|
128 * @publishedAll |
|
129 * @released |
|
130 */ |
|
131 template <class T> |
|
132 class TPagedMultiset : public TPagedMultisetBase |
|
133 { |
|
134 public: |
|
135 inline TPagedMultiset(); |
|
136 inline TPagedMultiset(const TPagedSetToken& aToken); |
|
137 // |
|
138 inline TBool ContainsL(const T& anObject) const; |
|
139 inline void InsertL(const T& anObject); |
|
140 inline void DeleteL(const T& anObject); |
|
141 }; |
|
142 |
|
143 /** |
|
144 * @publishedAll |
|
145 * @released |
|
146 */ |
|
147 TEMPLATE_SPECIALIZATION class TPagedMultiset<TAny> : public TPagedMultisetBase |
|
148 { |
|
149 public: |
|
150 inline TPagedMultiset(TInt anEntrySize); |
|
151 inline TPagedMultiset(const TPagedSetToken& aToken,TInt anEntrySize); |
|
152 }; |
|
153 |
|
154 /** |
|
155 * @publishedAll |
|
156 * @released |
|
157 */ |
|
158 class TPagedSetIterBase |
|
159 { |
|
160 public: |
|
161 IMPORT_C TBool ResetL(); |
|
162 IMPORT_C TBool NextL(); |
|
163 IMPORT_C void ExtractAtL(TAny* aPtr) const; |
|
164 protected: |
|
165 inline TPagedSetIterBase(const TPagedSetBase& aSet); |
|
166 private: |
|
167 const TBtreeFixBase* iTree; |
|
168 TBtreeMark iMark; |
|
169 }; |
|
170 |
|
171 /** |
|
172 * @publishedAll |
|
173 * @released |
|
174 */ |
|
175 template <class T> |
|
176 class TPagedSetIter : public TPagedSetIterBase |
|
177 { |
|
178 public: |
|
179 inline TPagedSetIter(const TPagedSet<T>& aSet); |
|
180 inline TPagedSetIter(const TPagedMultiset<T>& aSet); |
|
181 inline T AtL() const; |
|
182 inline void ExtractAtL(T& anObject) const; |
|
183 }; |
|
184 |
|
185 /** |
|
186 * @publishedAll |
|
187 * @released |
|
188 */ |
|
189 TEMPLATE_SPECIALIZATION class TPagedSetIter<TAny> : public TPagedSetIterBase |
|
190 { |
|
191 public: |
|
192 inline TPagedSetIter(const TPagedSetBase& aSet); |
|
193 }; |
|
194 |
|
195 /** |
|
196 * @publishedAll |
|
197 * @released |
|
198 */ |
|
199 class TPagedSetBiIterBase |
|
200 { |
|
201 public: |
|
202 IMPORT_C TBool FirstL(); |
|
203 IMPORT_C TBool LastL(); |
|
204 IMPORT_C TBool NextL(); |
|
205 IMPORT_C TBool PreviousL(); |
|
206 IMPORT_C void ExtractAtL(TAny* aPtr) const; |
|
207 protected: |
|
208 inline TPagedSetBiIterBase(const TPagedSetBase& aSet); |
|
209 private: |
|
210 const TBtreeFixBase* iTree; |
|
211 TBtreePos iPos; |
|
212 }; |
|
213 |
|
214 /** |
|
215 * @publishedAll |
|
216 * @released |
|
217 */ |
|
218 template <class T> |
|
219 class TPagedSetBiIter : public TPagedSetBiIterBase |
|
220 { |
|
221 public: |
|
222 inline TPagedSetBiIter(const TPagedSet<T>& aSet); |
|
223 inline TPagedSetBiIter(const TPagedMultiset<T>& aSet); |
|
224 inline T AtL() const; |
|
225 inline void ExtractAtL(T& anObject) const; |
|
226 }; |
|
227 |
|
228 /** |
|
229 * @publishedAll |
|
230 * @released |
|
231 */ |
|
232 TEMPLATE_SPECIALIZATION class TPagedSetBiIter<TAny> : public TPagedSetBiIterBase |
|
233 { |
|
234 public: |
|
235 inline TPagedSetBiIter(const TPagedSetBase& aSet); |
|
236 }; |
|
237 |
|
238 /** |
|
239 * @publishedAll |
|
240 * @released |
|
241 */ |
|
242 class TPagedSetRIterBase |
|
243 { |
|
244 public: |
|
245 inline TBool ResetL(); |
|
246 inline TBool NextL(); |
|
247 inline void ExtractAtL(TAny* aPtr) const; |
|
248 protected: |
|
249 inline TPagedSetRIterBase(const TPagedSetBase& aSet); |
|
250 private: |
|
251 TPagedSetBiIter<TAny> iIter; |
|
252 }; |
|
253 |
|
254 /** |
|
255 * @publishedAll |
|
256 * @released |
|
257 */ |
|
258 template <class T> |
|
259 class TPagedSetRIter : public TPagedSetRIterBase |
|
260 { |
|
261 public: |
|
262 inline TPagedSetRIter(const TPagedSet<T>& aSet); |
|
263 inline TPagedSetRIter(const TPagedMultiset<T>& aSet); |
|
264 inline T AtL() const; |
|
265 inline void ExtractAtL(T& anObject) const; |
|
266 }; |
|
267 |
|
268 /** |
|
269 * @publishedAll |
|
270 * @released |
|
271 */ |
|
272 TEMPLATE_SPECIALIZATION class TPagedSetRIter<TAny> : public TPagedSetRIterBase |
|
273 { |
|
274 public: |
|
275 inline TPagedSetRIter(const TPagedSetBase& aSet); |
|
276 }; |
|
277 |
|
278 #include <s32cont.inl> |
|
279 #endif |