2 * Copyright (c) 2005-2006 Nokia Corporation and/or its subsidiary(-ies).
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".
9 * Initial Contributors:
10 * Nokia Corporation - initial contribution.
14 * Description: CPosLandmark class
19 #ifndef CPOSLANDMARK_H
20 #define CPOSLANDMARK_H
23 #include <lbsfields.h>
26 #include "EPos_Landmarks.h"
32 * This is a container class for a landmark.
34 * A landmark is principally a location with a name.
36 * The landmark object can either be created by a client or retrieved from
37 * @ref CPosLandmarkDatabase.
39 * A landmark consists of a number of landmark attributes, e.g. landmark name,
40 * landmark position, coverage area, etc.
42 * A landmark may also contain generic position fields. These position fields
43 * are defined in LbsFieldIds.h. Only text fields are supported.If the client
44 * wants to store a non-text field, the value must first be converted to a
45 * textual representation.
46 * EPositionPlaceId position field added in extension of TPositionFieldId to support Place id
47 * EPositionTimeStamp position field added in extension of TPositionFieldId to support TimeStamp
49 * CPosLandmark contains functions for setting and getting landmark attributes
50 * and position fields.
52 * Note: CPosLandmark is only a local representation of the landmark. To
53 * update the database, call @ref CPosLandmarkDatabase::UpdateLandmarkL (or
54 * @ref CPosLandmarkDatabase::AddLandmarkL for a new landmark).
56 * @lib eposlandmarks.lib
59 class CPosLandmark : public CBase
64 * Bitmap for specifying a group of landmark attributes. Bit values are
65 * defined by @ref _TAttributes.
67 typedef TUint32 TAttributes;
70 * Specifies a landmark attribute such as landmark name or landmark
76 * No attribute specified.
78 ENoAttribute = 0x0000 ,
80 * The name of the landmark.
82 ELandmarkName = 0x0001 ,
84 * The position of the landmark.
88 * The landmark coverage radius.
90 ECoverageRadius = 0x0004 ,
92 * The categories of the landmark.
94 ECategoryInfo = 0x0008 ,
96 * The icon that represents the landmark in a UI.
100 * A description of the landmark.
102 EDescription = 0x0020 ,
104 * PlaceId for the landmark
108 * Timestamp associated with the landmark
110 ETimeStamp = 0x0080 ,
112 * All landmark attributes.
114 EAllAttributes = 0xFFFF
120 * Two-phased constructor.
122 * @returns A new instance of this class.
124 IMPORT_C static CPosLandmark* NewLC();
127 * Two-phased constructor.
129 * @returns A new instance of this class.
131 IMPORT_C static CPosLandmark* NewL();
134 * Two-phased copy constructor.
136 * @param[in] aLandmark The landmark to copy.
137 * @returns A copy of the specified landmark object.
139 IMPORT_C static CPosLandmark* NewLC(
140 const CPosLandmark& aLandmark
144 * Two-phased copy constructor.
146 * @param[in] aLandmark The landmark to copy.
147 * @returns A copy of the specified landmark object.
149 IMPORT_C static CPosLandmark* NewL(
150 const CPosLandmark& aLandmark
156 virtual ~CPosLandmark();
161 * Reads the ID of the landmark entry in the database.
163 * @returns The ID of the landmark entry in the database, or
164 * @p KPosLmNullItemId if the landmark has not been added to the
167 IMPORT_C TPosLmItemId LandmarkId() const;
170 * Checks if the landmark is partial.
172 * A client can read partial information about a landmark from the
173 * database. This function checks if only partial information is
174 * included in the landmark object. Partial landmark can not be used
175 * with @ref CPosLandmarkDatabase::UpdateLandmarkL().
177 * For more about partial landmarks, see
178 * @ref CPosLandmarkDatabase::ReadPartialLandmarkLC().
180 * @returns @p EFalse if the landmark contains all the landmark
181 * information, otherwise @p ETrue.
183 IMPORT_C TBool IsPartial() const;
186 * Reads the name of the landmark.
188 * This function returns error code @p KErrNotFound if the landmark
189 * name is not set in this landmark object. This will be the case if
190 * the landmark is read from the database using partial read and
191 * landmark name is excluded. Note that if a landmark is fully read
192 * from the database, the landmark name will always be included. If no
193 * name has been set for the landmark in the database, it will
194 * have an empty name string "".
196 * @param[out] aLandmarkName On return contains the landmark name.
197 * @returns @p KErrNone if successful, @p KErrNotFound if the landmark
198 * name is not specified.
200 IMPORT_C TInt GetLandmarkName(
205 * Sets the name of the landmark.
207 * If no name is set for the landmark when it is written to the database,
208 * the landmark in the database will have an empty name string "".
210 * @param[in] aLandmarkName The landmark name.
212 * @leave KErrArgument If the name of the landmark is longer than
213 * @p KPosLmMaxTextFieldLength
215 IMPORT_C void SetLandmarkNameL(
216 const TDesC& aLandmarkName
220 * Reads the landmark position.
222 * @param[out] aPosition On return contains the landmark position.
223 * @returns @p KErrNone if successful, @p KErrNotFound if the landmark
224 * position is not set.
226 IMPORT_C TInt GetPosition(
231 * Sets the landmark position.
233 * Latitude and longitude must be set in the position.
235 * Only WGS 84 coordinates are allowed. @p KPositionDatumWgs84 must be set as datum.
237 * @param[in] aPosition The landmark position.
239 * @leave KErrArgument Latitude and/or longitude is not set or other datum
240 * than @p KPositionDatumWgs84 is used in @p aPosition.
242 IMPORT_C void SetPositionL(
243 const TLocality& aPosition
247 * Reads the landmark coverage radius.
249 * Coverage radius is set if the landmark is big, e.g. a city. It
250 * defines the size of the area which the landmark represents.
252 * @param[out] aCoverageRadius On return contains the coverage radius.
253 * @returns @p KErrNone if successful, @p KErrNotFound if the landmark
254 * coverage radius is not set.
256 IMPORT_C TInt GetCoverageRadius(
257 TReal32& aCoverageRadius
261 * Sets the landmark coverage radius.
263 * Coverage radius is set if the landmark is big, e.g. a city. It
264 * defines the size of the area which the landmark represents.
266 * If coverage radius is set to NaN, then the coverage radius will be
269 * @param aCoverageRadius The coverage radius.
271 IMPORT_C void SetCoverageRadius(
272 TReal32 aCoverageRadius
276 * Adds a category to the landmark.
278 * If the specified category has already been added, nothing happens.
280 * @param aCategoryId The category to add.
282 IMPORT_C void AddCategoryL(
283 TPosLmItemId aCategoryId
287 * Removes a category from the landmark.
289 * If the specified category is not in the landmark, nothing happens.
291 * @param aCategoryId The category to remove
293 IMPORT_C void RemoveCategory(
294 TPosLmItemId aCategoryId
298 * Retrieves the database item IDs for the categories contained in this
301 * @param[out] aCategoryIdArray On return contains the list of this
302 * landmark's categories.
304 IMPORT_C void GetCategoriesL(
305 RArray<TPosLmItemId>& aCategoryIdArray
309 * Checks if the landmark contains a specific position field.
311 * @param aFieldId The position field.
312 * @returns @p ETrue if the landmark contains the field, otherwise
315 IMPORT_C TBool IsPositionFieldAvailable(
316 TPositionFieldId aFieldId
320 * Returns the number of position fields set in the landmark.
322 * @returns The number of position fields set in the landmark.
324 IMPORT_C TUint NumOfAvailablePositionFields() const;
327 * Returns the first position field contained in the landmark.
329 * This function is used to initiate iteration over the position fields.
330 * @ref NextPositionFieldId() is called to continue the iteration.
332 * @returns The first position field contained by the landmark, or
333 * @p EPositionFieldNone if there are no position fields in the
336 IMPORT_C TPositionFieldId FirstPositionFieldId() const;
339 * Returns the next position field contained in the landmark.
341 * This function is used to iterate the position fields in the landmark.
342 * @ref FirstPositionFieldId() is called to get the first ID. This ID is
343 * passed to @ref NextPositionFieldId() to obtain the second ID, etc.
345 * If the client specifies an ID which is not contained in the landmark,
346 * this function will panic with code @p EPosInvalidPositionFieldId. It
347 * is therefore important that the client does not remove the current
348 * field while iterating. If the client still removes the current field,
349 * the client must pass the previous field.
351 * @param aFieldId The last position field which was read.
352 * @returns The next position field contained by the landmark, or
353 * @p EPositionFieldNone if there are no more position fields in the
356 * @panic "Landmarks Client"-EPosInvalidPositionFieldId Client specified a field ID,
357 * which is not contained in the landmark.
359 IMPORT_C TPositionFieldId NextPositionFieldId(
360 TPositionFieldId aFieldId
364 * Reads the value of a position field.
366 * @param[in] aFieldId The position field to read.
367 * @param[out] aFieldValue On return contains the value of the position field.
368 * @returns @p KErrNone if successful, @p KErrNotFound if the landmark
369 * does not contain the specified position field.
371 IMPORT_C TInt GetPositionField(
372 TPositionFieldId aFieldId,
377 * Sets a position field in the landmark.
379 * @param[in] aFieldId The position field to set.
380 * @param[in] aFieldValue The new value for the position field.
382 * @leave KErrArgument If the position field text is longer than
383 * @p KPosLmMaxTextFieldLength.
385 IMPORT_C void SetPositionFieldL(
386 TPositionFieldId aFieldId,
387 const TDesC& aFieldValue
391 * Removes a position field from the landmark.
393 * If the specified position field is not contained in the landmark,
394 * nothing will happen.
396 * @param aFieldId The position field to remove.
398 IMPORT_C void RemovePositionField(
399 TPositionFieldId aFieldId
403 * Associates the landmark with an icon.
405 * Icons are found in icon files. To set an icon, the client
406 * must specify the name of the icon file and the index of the
407 * icon within the file.
409 * The landmark is not affected if the icon file is changed or
410 * removed. It only contains a link to the icon.
412 * @param[in] aIconFileName The full icon file name.
413 * @param[in] aIconIndex The index of the icon within the icon file.
414 * @param[in] aIconMaskIndex The index of the icon mask within the
417 * @leave KErrArgument The icon file name is longer than @p KMaxFileName.
419 * @panic "Landmarks Client"-EPosLmInvalidArgument The icon index is negative or
420 * the icon mask index is negative and not equal to @p KPosLmIconMaskNotUsed.
422 IMPORT_C void SetIconL(
423 const TDesC& aIconFileName,
429 * Returns the link to the icon associated with the landmark.
431 * Icons are found in icon files. It is referenced by the name of
432 * the icon file and the index of the icon within the file.
434 * The landmark is not affected if the icon file is changed or
435 * removed. It only contains a link to the icon. This means that the
436 * link could be invalid.
438 * @param[out] aIconFileName The full icon file name.
439 * @param[out] aIconIndex The index of the icon within the icon file.
440 * @param[out] aIconMaskIndex The index of the icon mask within the
441 * icon file. If no icon mask index is defined @p KPosLmIconMaskNotUsed
444 * @returns @p KErrNone if successful, @p KErrNotFound if the icon is
447 IMPORT_C TInt GetIcon(
448 TPtrC& aIconFileName,
454 * Reads the description of the landmark.
456 * This function returns error code @p KErrNotFound if the landmark
457 * description is not set in this landmark object. This will be the case
458 * if the landmark is read from the database using partial read and
459 * landmark description is excluded. Note that if a landmark is fully
460 * read from the database, the landmark description is always
461 * included. If no description has been set for the landmark in
462 * the database, it is set to an empty string "".
464 * @param[out] aLandmarkDescription On return contains the landmark description.
465 * @returns @p KErrNone if successful, @p KErrNotFound if the landmark
466 * description is not specified.
468 IMPORT_C TInt GetLandmarkDescription(
469 TPtrC& aLandmarkDescription
473 * Sets a description for the landmark.
475 * If no description is set for the landmark when it is written to the
476 * database, the landmark in the database will have an empty description
479 * @param[in] aLandmarkDescription The landmark description.
481 * @leave KErrArgument The name of the landmark is longer than
482 * @p KPosLmMaxDescriptionLength.
484 IMPORT_C void SetLandmarkDescriptionL(
485 const TDesC& aLandmarkDescription
489 * Removes landmark attributes from the landmark.
491 * @param aAttributes A bitmap specifying which landmark attributes to
494 IMPORT_C void RemoveLandmarkAttributes(
495 TAttributes aAttributes
501 * Sets the partial update flag to the landmark.
502 * This flag is used to indicate if only partial information is included
503 * in the landmark object.
505 * @param aPartial @p EFalse if the landmark contains all the landmark
506 * information, otherwise @p ETrue.
515 * Sets the landmark ID to the landmark.
517 * @param aId The landmark ID to set.
524 * Sets the PlaceId for the landmark
525 * @param[in] aPId The place id of the landmark
526 * @leave Symbian error codes
528 IMPORT_C void SetPlaceIdL( const TDesC& aPId );
531 * Gets the PlaceId of the landmark
532 * @param[out] aPId On return contains the place id of the landmark
533 * @return KErrNone if successful , else KErrNotFound if PlaceId is
536 IMPORT_C TInt GetPlaceId( TPtrC& aPId ) const;
539 * Sets the timestamp of the landmark.
540 * @param[in] aTimeStamp Timestamp of the landmark(Full date & time)
541 * @leave KErrArgument If the full date & time have not been specified.
543 IMPORT_C void SetTimeStampL( const TTime aTimeStamp );
546 * Gets the timestamp of the landmark
547 * @param[out] aTimeStamp On return contains the timestamp of the landamrk
548 * @return KErrNone if successful , else KErrNotFound if TimeStamp is
551 IMPORT_C TInt GetTimeStamp( TTime& aTimeStamp )const;
558 // Prohibit copy constructor
559 CPosLandmark(const CPosLandmark&);
561 // Prohibit assigment operator
562 CPosLandmark& operator= (const CPosLandmark&);
565 void ConstructL(const CPosLandmark& aLandmark);
572 // Partial landmark flag
576 HBufC* iLandmarkName;
578 // Landmark position information
579 TLocality* iPosition;
581 // Landmark coverage radius
582 TReal32 iCoverageRadius;
584 // Landmark categories
585 RArray<TPosLmItemId> iCategoryArray;
587 // Landmark position field IDs
588 RArray<TUint> iPositionFieldIds;
590 // Landmark position field strings
591 CDesCArray* iPositionFieldStrings;
593 // Landmark icon filename
594 HBufC* iIconFileName;
596 // Landmark icon index
599 // Landmark icon mask index
602 // Landmark description
603 HBufC* iLandmarkDescription;
606 #endif // CPOSLANDMARK_H