williamr@2
|
1 |
/*
|
williamr@2
|
2 |
* Copyright (c) 2005-2006 Nokia Corporation and/or its subsidiary(-ies).
|
williamr@2
|
3 |
* All rights reserved.
|
williamr@2
|
4 |
* This component and the accompanying materials are made available
|
williamr@2
|
5 |
* under the terms of the License "Symbian Foundation License v1.0" to Symbian Foundation members and "Symbian Foundation End User License Agreement v1.0" to non-members
|
williamr@2
|
6 |
* which accompanies this distribution, and is available
|
williamr@2
|
7 |
* at the URL "http://www.symbianfoundation.org/legal/licencesv10.html".
|
williamr@2
|
8 |
*
|
williamr@2
|
9 |
* Initial Contributors:
|
williamr@2
|
10 |
* Nokia Corporation - initial contribution.
|
williamr@2
|
11 |
*
|
williamr@2
|
12 |
* Contributors:
|
williamr@2
|
13 |
*
|
williamr@2
|
14 |
* Description: CPosLandmarkSearch class
|
williamr@2
|
15 |
*
|
williamr@2
|
16 |
*/
|
williamr@2
|
17 |
|
williamr@2
|
18 |
|
williamr@2
|
19 |
#ifndef CPOSLANDMARKSEARCH_H
|
williamr@2
|
20 |
#define CPOSLANDMARKSEARCH_H
|
williamr@2
|
21 |
|
williamr@2
|
22 |
#include <e32base.h>
|
williamr@2
|
23 |
#include <EPos_CPosLandmarkDatabase.h>
|
williamr@2
|
24 |
#include <EPos_CPosLmCategoryManager.h>
|
williamr@2
|
25 |
#include <EPos_CPosLmItemIterator.h>
|
williamr@2
|
26 |
#include <EPos_CPosLmOperation.h>
|
williamr@2
|
27 |
#include <EPos_TPosLmSortPref.h>
|
williamr@2
|
28 |
|
williamr@2
|
29 |
class CPosLmSearchCriteria;
|
williamr@2
|
30 |
class CPosLmDisplayData;
|
williamr@2
|
31 |
|
williamr@2
|
32 |
const TInt KPosLmMaxNumOfMatchesUnlimited = -1;
|
williamr@2
|
33 |
|
williamr@2
|
34 |
/**
|
williamr@2
|
35 |
* This class is used to perform searches for landmarks or landmark categories
|
williamr@2
|
36 |
* in a landmark database.
|
williamr@2
|
37 |
*
|
williamr@2
|
38 |
* To search a landmark database, an instance of this class is created,
|
williamr@2
|
39 |
* supplying the database to search. The client creates a criterion object to
|
williamr@2
|
40 |
* specify what to search for. There are different criterion classes which all
|
williamr@2
|
41 |
* inherit from @ref CPosLmSearchCriteria. For instance, the client can search
|
williamr@2
|
42 |
* for landmarks which contain a certain text string by passing a
|
williamr@2
|
43 |
* @ref CPosLmTextCriteria.
|
williamr@2
|
44 |
*
|
williamr@2
|
45 |
* Some criterion classes are used for searching for landmarks (e.g.
|
williamr@2
|
46 |
* @ref CPosLmCategoryCriteria is used for searching for landmarks which
|
williamr@2
|
47 |
* contain a certain category) and some are used
|
williamr@2
|
48 |
* to search for landmark categories (e.g. @ref CPosLmCatNameCriteria is used
|
williamr@2
|
49 |
* to search for landmark categories by specifying a category name which may
|
williamr@2
|
50 |
* contain wild-card characters).
|
williamr@2
|
51 |
*
|
williamr@2
|
52 |
* Searches can be run in incremental mode.
|
williamr@2
|
53 |
* @ref StartLandmarkSearchL and @ref StartCategorySearchL both return a
|
williamr@2
|
54 |
* @p CPosLmOperation object which is used to execute the search. If it is
|
williamr@2
|
55 |
* run incrementally the client can supervise the progress of the operation.
|
williamr@2
|
56 |
* If it is sufficient to run the search synchronously, the client only has to
|
williamr@2
|
57 |
* call @p CPosLmOperation::ExecuteL. The client can cancel
|
williamr@2
|
58 |
* the search by deleting the @p CPosLmOperation object.
|
williamr@2
|
59 |
*
|
williamr@2
|
60 |
* By default, these functions start a new search, but the client can specify
|
williamr@2
|
61 |
* that only previous matches should be searched. This can be used to refine
|
williamr@2
|
62 |
* the search when there are many matches.
|
williamr@2
|
63 |
*
|
williamr@2
|
64 |
* During the search execution a read-lock is acquired for each database.
|
williamr@2
|
65 |
*
|
williamr@2
|
66 |
* Only one search can be performed at a time by the single instance of
|
williamr@2
|
67 |
* the class. If a search is already running, the search function leaves
|
williamr@2
|
68 |
* with error code @p KErrInUse.
|
williamr@2
|
69 |
*
|
williamr@2
|
70 |
* After search completion, the client can make a second search and specify
|
williamr@2
|
71 |
* that only the matches from the previous search shall be considered.
|
williamr@2
|
72 |
*
|
williamr@2
|
73 |
* The client can also set a limit on how many search matches should be
|
williamr@2
|
74 |
* returned (see @ref SetMaxNumOfMatches).
|
williamr@2
|
75 |
*
|
williamr@2
|
76 |
* The client retrieves the matches from the search by requesting an iterator
|
williamr@2
|
77 |
* (see @ref MatchIteratorL) or by using display data (see @ref SetDisplayData).
|
williamr@2
|
78 |
*
|
williamr@2
|
79 |
* @p NetworkServices capability is required for remote databases.
|
williamr@2
|
80 |
*
|
williamr@2
|
81 |
* @lib eposlmsearchlib.lib
|
williamr@2
|
82 |
* @since S60 3.0
|
williamr@2
|
83 |
*/
|
williamr@2
|
84 |
class CPosLandmarkSearch : public CBase
|
williamr@2
|
85 |
{
|
williamr@2
|
86 |
public:
|
williamr@2
|
87 |
|
williamr@2
|
88 |
/**
|
williamr@2
|
89 |
* Two-phased constructor.
|
williamr@2
|
90 |
*
|
williamr@2
|
91 |
* The client takes ownership of the returned search object.
|
williamr@2
|
92 |
*
|
williamr@2
|
93 |
* @param[in] aDatabase The landmark database to search.
|
williamr@2
|
94 |
* @returns A new instance of this class.
|
williamr@2
|
95 |
*/
|
williamr@2
|
96 |
IMPORT_C static CPosLandmarkSearch* NewL(
|
williamr@2
|
97 |
CPosLandmarkDatabase& aDatabase
|
williamr@2
|
98 |
);
|
williamr@2
|
99 |
|
williamr@2
|
100 |
/**
|
williamr@2
|
101 |
* Destructor.
|
williamr@2
|
102 |
*/
|
williamr@2
|
103 |
IMPORT_C virtual ~CPosLandmarkSearch();
|
williamr@2
|
104 |
|
williamr@2
|
105 |
public:
|
williamr@2
|
106 |
|
williamr@2
|
107 |
/**
|
williamr@2
|
108 |
* Retrieves the maximum number of search matches limit.
|
williamr@2
|
109 |
*
|
williamr@2
|
110 |
* By default the maximum number of matches is unlimited.
|
williamr@2
|
111 |
*
|
williamr@2
|
112 |
* @return The maximum number of search matches or
|
williamr@2
|
113 |
* @p KPosLmMaxNumOfMatchesUnlimited if unlimited.
|
williamr@2
|
114 |
*/
|
williamr@2
|
115 |
IMPORT_C TInt MaxNumOfMatches() const;
|
williamr@2
|
116 |
|
williamr@2
|
117 |
/**
|
williamr@2
|
118 |
* Sets the maximum number of search matches limit.
|
williamr@2
|
119 |
*
|
williamr@2
|
120 |
* If the limit is set, the search operation will stop when this limit
|
williamr@2
|
121 |
* is reached.
|
williamr@2
|
122 |
*
|
williamr@2
|
123 |
* By default the maximum number of matches is unlimited.
|
williamr@2
|
124 |
*
|
williamr@2
|
125 |
* If a new value for maximum number of matches is set when a search is
|
williamr@2
|
126 |
* ongoing, it will not affect the current search. The new maximum will
|
williamr@2
|
127 |
* be utilized in the next search.
|
williamr@2
|
128 |
*
|
williamr@2
|
129 |
* @param[in] aMaxNumOfMatches the maximum number of search matches.
|
williamr@2
|
130 |
* KPosLmMaxNumOfMatchesUnlimited means that the number of matches is
|
williamr@2
|
131 |
* unlimited.
|
williamr@2
|
132 |
*/
|
williamr@2
|
133 |
IMPORT_C void SetMaxNumOfMatches(
|
williamr@2
|
134 |
TInt aMaxNumOfMatches = KPosLmMaxNumOfMatchesUnlimited
|
williamr@2
|
135 |
);
|
williamr@2
|
136 |
|
williamr@2
|
137 |
/**
|
williamr@2
|
138 |
* Starts a search for landmarks.
|
williamr@2
|
139 |
*
|
williamr@2
|
140 |
* The client takes ownership of the returned operation object.
|
williamr@2
|
141 |
*
|
williamr@2
|
142 |
* This function requires @p ReadUserData capability.
|
williamr@2
|
143 |
*
|
williamr@2
|
144 |
* @param[in] aCriteria The search criterion.
|
williamr@2
|
145 |
* @param[in] aSearchOnlyPreviousMatches This flag may be used to perform a
|
williamr@2
|
146 |
* search within the results of previous search.
|
williamr@2
|
147 |
* @returns A handle to the search operation.
|
williamr@2
|
148 |
*
|
williamr@2
|
149 |
* @leave KErrInUse Search is already running.
|
williamr@2
|
150 |
* @leave KErrNotSupported search criterion is not supported.
|
williamr@2
|
151 |
* @leave KErrArgument Search criterion is not valid for landmark searching.
|
williamr@2
|
152 |
* @leave KErrArgument There are no previous matches and the client specifies that
|
williamr@2
|
153 |
* previous matches should be used.
|
williamr@2
|
154 |
*/
|
williamr@2
|
155 |
virtual CPosLmOperation* StartLandmarkSearchL(
|
williamr@2
|
156 |
const CPosLmSearchCriteria& aCriteria,
|
williamr@2
|
157 |
TBool aSearchOnlyPreviousMatches = EFalse
|
williamr@2
|
158 |
) = 0;
|
williamr@2
|
159 |
|
williamr@2
|
160 |
/**
|
williamr@2
|
161 |
* Starts a search for landmarks.
|
williamr@2
|
162 |
*
|
williamr@2
|
163 |
* This overload of the @ref StartLandmarkSearchL function lets the
|
williamr@2
|
164 |
* client define the sort order for the search matches.
|
williamr@2
|
165 |
* Only sorting by landmark name is supported.
|
williamr@2
|
166 |
*
|
williamr@2
|
167 |
* The client takes ownership of the returned operation object.
|
williamr@2
|
168 |
*
|
williamr@2
|
169 |
* This function requires @p ReadUserData capability.
|
williamr@2
|
170 |
*
|
williamr@2
|
171 |
* @param[in] aCriteria The search criterion.
|
williamr@2
|
172 |
* @param[in] aSortPref A sort preference object.
|
williamr@2
|
173 |
* @param[in] aSearchOnlyPreviousMatches This flag may be used to perform a
|
williamr@2
|
174 |
* search within the results of previous search.
|
williamr@2
|
175 |
* @returns A handle to the search operation.
|
williamr@2
|
176 |
*
|
williamr@2
|
177 |
* @leave KErrInUse Search is already running.
|
williamr@2
|
178 |
* @leave KErrArgument Search criterion is not valid for landmark searching.
|
williamr@2
|
179 |
* @leave KErrArgument There are no previous matches and the client specifies that
|
williamr@2
|
180 |
* previous matches should be used.
|
williamr@2
|
181 |
* @leave KErrNotSupported Search criterion is not supported.
|
williamr@2
|
182 |
* @leave KErrNotSupported Client tries to sort by other attribute than name.
|
williamr@2
|
183 |
*/
|
williamr@2
|
184 |
virtual CPosLmOperation* StartLandmarkSearchL(
|
williamr@2
|
185 |
const CPosLmSearchCriteria& aCriteria,
|
williamr@2
|
186 |
const TPosLmSortPref& aSortPref,
|
williamr@2
|
187 |
TBool aSearchOnlyPreviousMatches = EFalse
|
williamr@2
|
188 |
) = 0;
|
williamr@2
|
189 |
|
williamr@2
|
190 |
/**
|
williamr@2
|
191 |
* Starts a search for landmark categories.
|
williamr@2
|
192 |
*
|
williamr@2
|
193 |
* The criterion which defines whether a landmark category is a match or
|
williamr@2
|
194 |
* not is passed as input to this function.
|
williamr@2
|
195 |
*
|
williamr@2
|
196 |
* The client takes ownership of the returned operation object.
|
williamr@2
|
197 |
*
|
williamr@2
|
198 |
* This function requires @p ReadUserData capability.
|
williamr@2
|
199 |
*
|
williamr@2
|
200 |
* @param[in] aCriteria The search criterion.
|
williamr@2
|
201 |
* @param[in] aSortPref Sort preference for the search results.
|
williamr@2
|
202 |
* @param[in] aSearchOnlyPreviousMatches This flag may be used to perform a
|
williamr@2
|
203 |
* search within the results of previous search.
|
williamr@2
|
204 |
* @returns A handle to the search operation.
|
williamr@2
|
205 |
*
|
williamr@2
|
206 |
* @leave KErrInUse Search is already running.
|
williamr@2
|
207 |
* @leave KErrArgument Search criterion is not valid for category searching.
|
williamr@2
|
208 |
* @leave KErrNotSupported Search criterion is not supported.
|
williamr@2
|
209 |
*/
|
williamr@2
|
210 |
virtual CPosLmOperation* StartCategorySearchL(
|
williamr@2
|
211 |
const CPosLmSearchCriteria& aCriteria,
|
williamr@2
|
212 |
CPosLmCategoryManager::TCategorySortPref aSortPref,
|
williamr@2
|
213 |
TBool aSearchOnlyPreviousMatches = EFalse
|
williamr@2
|
214 |
) = 0;
|
williamr@2
|
215 |
|
williamr@2
|
216 |
/**
|
williamr@2
|
217 |
* Returns the number of matches so far in the search.
|
williamr@2
|
218 |
*
|
williamr@2
|
219 |
* This function can also be called during a search operation.
|
williamr@2
|
220 |
*
|
williamr@2
|
221 |
* @return The number of search matches.
|
williamr@2
|
222 |
*/
|
williamr@2
|
223 |
virtual TUint NumOfMatches() const = 0;
|
williamr@2
|
224 |
|
williamr@2
|
225 |
/**
|
williamr@2
|
226 |
* Creates an iterator object to iterate the matching landmarks or
|
williamr@2
|
227 |
* landmark categories.
|
williamr@2
|
228 |
*
|
williamr@2
|
229 |
* This function can also be called during a search in order to read the
|
williamr@2
|
230 |
* matches encountered so far. Note that the iterator will not iterate
|
williamr@2
|
231 |
* any new matches. If new matches are found, a new iterator must be
|
williamr@2
|
232 |
* created.
|
williamr@2
|
233 |
*
|
williamr@2
|
234 |
* If a sort preference was specified when the search was started,
|
williamr@2
|
235 |
* the landmarks/categories will be sorted when the search is complete
|
williamr@2
|
236 |
* but the items are not necessarily sorted if this function is called
|
williamr@2
|
237 |
* during a search.
|
williamr@2
|
238 |
*
|
williamr@2
|
239 |
* Note: If the client has set display data and resets the display data
|
williamr@2
|
240 |
* during a search, the sort order in the iterator might be incorrect.
|
williamr@2
|
241 |
*
|
williamr@2
|
242 |
* The client takes ownership of the returned iterator object.
|
williamr@2
|
243 |
*
|
williamr@2
|
244 |
* Note that the iterator iterates matches in @ref CPosLandmarkSearch.
|
williamr@2
|
245 |
* It cannot be used after the search object has been deleted. Make sure
|
williamr@2
|
246 |
* to delete the iterator first.
|
williamr@2
|
247 |
*
|
williamr@2
|
248 |
* @return A search match iterator.
|
williamr@2
|
249 |
*/
|
williamr@2
|
250 |
virtual CPosLmItemIterator* MatchIteratorL() = 0;
|
williamr@2
|
251 |
|
williamr@2
|
252 |
/**
|
williamr@2
|
253 |
* Display data can be used as an alternative way to get result
|
williamr@2
|
254 |
* from a database search. Landmarks or categories are added to the
|
williamr@2
|
255 |
* display data collection during a search depending on the search type.
|
williamr@2
|
256 |
*
|
williamr@2
|
257 |
* This function may replace the combination of using
|
williamr@2
|
258 |
* @ref MatchIteratorL and reading landmark or category data.
|
williamr@2
|
259 |
* Result data is read already during the search and no duplicate
|
williamr@2
|
260 |
* access to database is needed.
|
williamr@2
|
261 |
*
|
williamr@2
|
262 |
* The display data object will be reset each time a new search is
|
williamr@2
|
263 |
* started. No items during the search are removed from the
|
williamr@2
|
264 |
* collection. New found matches can be added every time next
|
williamr@2
|
265 |
* search step is completed, see @ref CPosLmDisplayData::NewItemIndex.
|
williamr@2
|
266 |
*
|
williamr@2
|
267 |
* Note: The database index of displayable data items in
|
williamr@2
|
268 |
* @ref CPosLmDisplayData will be set to 0 as it has no meaning in a
|
williamr@2
|
269 |
* single database search.
|
williamr@2
|
270 |
*
|
williamr@2
|
271 |
* The client owns the display data object. If the client deletes it
|
williamr@2
|
272 |
* during a search, this may lead to unexpected errors. The client must
|
williamr@2
|
273 |
* call @ref UnsetDisplayData before it deletes the display data object.
|
williamr@2
|
274 |
*
|
williamr@2
|
275 |
* Note: If the client resets the display data during a search, the sort
|
williamr@2
|
276 |
* order in the iterator might become incorrect.
|
williamr@2
|
277 |
*
|
williamr@2
|
278 |
* @param[in,out] aData The displayable data.
|
williamr@2
|
279 |
*
|
williamr@2
|
280 |
* @panic "Landmarks Client"-EPosSearchOperationInUse
|
williamr@2
|
281 |
* The client set display data during an ongoing search.
|
williamr@2
|
282 |
*/
|
williamr@2
|
283 |
virtual void SetDisplayData( CPosLmDisplayData& aData ) = 0;
|
williamr@2
|
284 |
|
williamr@2
|
285 |
/**
|
williamr@2
|
286 |
* Unsets display data. No further data will be added to the display
|
williamr@2
|
287 |
* data that was set with @ref SetDisplayData.
|
williamr@2
|
288 |
*
|
williamr@2
|
289 |
* @panic "Landmarks Client"-EPosSearchOperationInUse
|
williamr@2
|
290 |
* The client unset display data during an ongoing search.
|
williamr@2
|
291 |
*/
|
williamr@2
|
292 |
virtual void UnsetDisplayData() = 0;
|
williamr@2
|
293 |
|
williamr@2
|
294 |
protected:
|
williamr@2
|
295 |
|
williamr@2
|
296 |
// C++ constructor.
|
williamr@2
|
297 |
IMPORT_C CPosLandmarkSearch();
|
williamr@2
|
298 |
|
williamr@2
|
299 |
private:
|
williamr@2
|
300 |
|
williamr@2
|
301 |
// Prohibit copy constructor
|
williamr@2
|
302 |
CPosLandmarkSearch( const CPosLandmarkSearch& );
|
williamr@2
|
303 |
// Prohibit assigment operator
|
williamr@2
|
304 |
CPosLandmarkSearch& operator= ( const CPosLandmarkSearch& );
|
williamr@2
|
305 |
|
williamr@2
|
306 |
private:
|
williamr@2
|
307 |
|
williamr@2
|
308 |
TUid iDtorIdKey;
|
williamr@2
|
309 |
TInt iMaxNumOfMatches;
|
williamr@2
|
310 |
};
|
williamr@2
|
311 |
|
williamr@2
|
312 |
#endif // CPOSLANDMARKSEARCH_H
|
williamr@2
|
313 |
|
williamr@2
|
314 |
|