|
1 /* |
|
2 * Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: Utility class to hold data for predictive search. |
|
15 * Used to marshal data between the client, server and |
|
16 * data plugins. |
|
17 * |
|
18 */ |
|
19 |
|
20 #ifndef __C_PS_DATA_H__ |
|
21 #define __C_PS_DATA_H__ |
|
22 |
|
23 // SYSTEM INCLUDES |
|
24 #include <e32base.h> |
|
25 #include <s32strm.h> |
|
26 #include <e32math.h> |
|
27 |
|
28 // CLASS DECLARATION |
|
29 |
|
30 /** |
|
31 * Utility class to store data for predictive search. |
|
32 * This is the basic data class that is used to marshal data between |
|
33 * the client, server and data plugins. |
|
34 * |
|
35 * @lib pcsutils.lib |
|
36 * @since S60 v3.2 |
|
37 */ |
|
38 class CPsData : public CBase |
|
39 { |
|
40 |
|
41 public: |
|
42 |
|
43 /** |
|
44 * Two phase construction |
|
45 * @return Instance of CPsData |
|
46 */ |
|
47 IMPORT_C static CPsData* NewL(); |
|
48 |
|
49 /** |
|
50 * Destructor |
|
51 */ |
|
52 IMPORT_C ~CPsData(); |
|
53 |
|
54 /** |
|
55 * Provides the unique identifier of this object |
|
56 * |
|
57 * @return Unique identifier of this object |
|
58 */ |
|
59 IMPORT_C TInt Id() const; |
|
60 |
|
61 /** |
|
62 * Sets the unique identifier of this object |
|
63 * @param aId The unique identifier |
|
64 */ |
|
65 IMPORT_C void SetId(const TInt aId); |
|
66 |
|
67 |
|
68 /** |
|
69 * Provides the unique URI identifier of this object |
|
70 * |
|
71 * @return Unique URI identifier of this object |
|
72 */ |
|
73 IMPORT_C TUint8 UriId() const; |
|
74 |
|
75 /** |
|
76 * Sets the unique URI identifier of this object |
|
77 * @param aUriId The unique URI identifier |
|
78 */ |
|
79 IMPORT_C void SetUriId(const TUint8 aUriId); |
|
80 |
|
81 /** |
|
82 * Pointer to the data element at the specified location |
|
83 * |
|
84 * @param aIndex Index of data element |
|
85 * @param Pointer to data element |
|
86 */ |
|
87 IMPORT_C HBufC* Data(TInt aIndex) const; |
|
88 |
|
89 /** |
|
90 * Sets the data at the specified location |
|
91 * |
|
92 * @param aIndex Index of data element |
|
93 * @param aData Data descriptor to be searched |
|
94 */ |
|
95 IMPORT_C void SetDataL(const TInt aIndex, |
|
96 const TDesC& aData); |
|
97 |
|
98 /** |
|
99 * Writes 'this' to the stream |
|
100 * |
|
101 * @param aStream WriteStream with externalized contents |
|
102 */ |
|
103 IMPORT_C virtual void ExternalizeL(RWriteStream& aStream) const; |
|
104 |
|
105 /** |
|
106 * Initializes 'this' from stream |
|
107 * |
|
108 * @param aStream ReadStream with data contents to be internalized |
|
109 */ |
|
110 IMPORT_C virtual void InternalizeL(RReadStream& aStream); |
|
111 |
|
112 /** |
|
113 * Method to compare two CPsData objects |
|
114 * |
|
115 * @param aObject1 Instance 1 to be compared |
|
116 * @param aObject2 Instance 2 to be compared |
|
117 * @return 0 if aObject1 == aObject2 |
|
118 * -1 if aObject1 < aObject2 |
|
119 * 1 if aObject1 > aObject2 |
|
120 */ |
|
121 IMPORT_C static TInt CompareByData ( const CPsData& aObject1, |
|
122 const CPsData& aObject2 ); |
|
123 |
|
124 /** |
|
125 * Method to compare two CPsData objects based on unique Id |
|
126 * |
|
127 * @param aObject1 Instance 1 to be compared |
|
128 * @param aObject2 Instance 2 to be compared |
|
129 * @return ETrue if aObject1 == aObject2 |
|
130 * else EFalse |
|
131 */ |
|
132 IMPORT_C static TBool CompareById(const CPsData& aObject1, |
|
133 const CPsData& aObject2); |
|
134 |
|
135 /** |
|
136 * Checks if data at array index is matched for predictive search |
|
137 * |
|
138 * @param aIndex Index of data element |
|
139 * @return TRUE if matched for predictive search |
|
140 * FALSE if not matched for predictive search |
|
141 */ |
|
142 IMPORT_C TBool IsDataMatch(TInt aIndex); |
|
143 |
|
144 /** |
|
145 * Sets data at array index has matched for predictive search |
|
146 * |
|
147 * @param aIndex Index of data element |
|
148 */ |
|
149 IMPORT_C void SetDataMatch(TInt aIndex); |
|
150 |
|
151 /** |
|
152 * Returns the data match attribute |
|
153 * |
|
154 * @return Data Match Attribute |
|
155 */ |
|
156 IMPORT_C TUint8 DataMatch(); |
|
157 |
|
158 /** |
|
159 * Clear all the bits set in data matches |
|
160 */ |
|
161 IMPORT_C void ClearDataMatches(); |
|
162 |
|
163 /** |
|
164 * Returns the number of data elements |
|
165 * |
|
166 * @return Number of data elements |
|
167 */ |
|
168 IMPORT_C TInt DataElementCount() const; |
|
169 |
|
170 /** |
|
171 * Returns the data extension |
|
172 * |
|
173 * @return Pointer to data extension if supported. Else NULL. |
|
174 */ |
|
175 IMPORT_C TAny* DataExtension() const; |
|
176 |
|
177 /** |
|
178 * Set the data extension |
|
179 * |
|
180 * @param aDataExt Data Extension for this object |
|
181 */ |
|
182 IMPORT_C void SetDataExtension(TAny* aDataExt); |
|
183 |
|
184 /** |
|
185 * Add element to the Integer Data Extention |
|
186 * |
|
187 * @param aDataExt - Integer Data Extension to be added |
|
188 */ |
|
189 IMPORT_C void AddIntDataExtL(TInt aDataExt); |
|
190 |
|
191 /** |
|
192 * Remove element from the Integer Data Extention |
|
193 * |
|
194 * @param aIndex - Integer Data Extension array index |
|
195 */ |
|
196 IMPORT_C void RemoveIntDataExt(TInt aIndex); |
|
197 |
|
198 /** |
|
199 * Retrieve Integer Data Extention Array |
|
200 * |
|
201 * @param aDataExtArray - Integer Data Extension array |
|
202 */ |
|
203 |
|
204 IMPORT_C void IntDataExt(RArray<TInt>& aDataExtArray); |
|
205 |
|
206 private: |
|
207 |
|
208 /** |
|
209 * Default Constructor |
|
210 */ |
|
211 CPsData(); |
|
212 |
|
213 /** |
|
214 * Second phase constructor |
|
215 */ |
|
216 void ConstructL(); |
|
217 |
|
218 private: |
|
219 |
|
220 /** |
|
221 * Unique id |
|
222 */ |
|
223 TInt iId; |
|
224 |
|
225 /** |
|
226 * URI ID. Indicates the data source. |
|
227 */ |
|
228 TUint8 iUriId; |
|
229 |
|
230 /** |
|
231 * Indicates in bit positions, what data fields |
|
232 * are matched for predictive search |
|
233 */ |
|
234 TUint8 iDataMatches; |
|
235 |
|
236 /** |
|
237 * Data fields |
|
238 */ |
|
239 RPointerArray<HBufC>* iData; |
|
240 |
|
241 /** |
|
242 * Extended Data field |
|
243 */ |
|
244 TAny* iDataExtension; |
|
245 |
|
246 /** |
|
247 * Extended Data field of Integers |
|
248 */ |
|
249 RArray<TInt>* iIntDataExt; |
|
250 |
|
251 /** |
|
252 * Garbage collector to fix performance issue |
|
253 */ |
|
254 RPointerArray<HBufC>* iGc; |
|
255 }; |
|
256 |
|
257 #endif // __C_PS_DATA_H__ |
|
258 |
|
259 // End of file |