2 * Copyright (c) 2002 Nokia Corporation and/or its subsidiary(-ies).
4 * This component and the accompanying materials are made available
5 * under the terms of the License "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: Declaration of FavouritesItemList
19 #ifndef FAVOURITES_ITEM_LIST_H
20 #define FAVOURITES_ITEM_LIST_H
28 // FORWARD DECLARATION
30 class CFavouritesItem;
37 * CFavouritesItemList is the Array of CFavouritesItem-s.
38 * Items are owned and deleted upon destruction.
39 * Note: using this array downcasted to its base can result in leaks.
40 * Delete method of base class is not virtual!
42 class CFavouritesItemList: public CArrayPtrFlat<CFavouritesItem>
44 public: // Constructor and destructor
50 IMPORT_C CFavouritesItemList();
53 * Destructor. Elements are destroyed.
56 IMPORT_C virtual ~CFavouritesItemList();
58 public: // new methods
61 * Remove and destroy an element. Invalid params will Panic.
63 * @param aIndex Index of element to delete.
66 IMPORT_C void Delete( TInt aIndex );
69 * Remove and destroy elements. Invalid params Panic.
71 * @param aIndex Index of start element to delete.
72 * @param aCount Number of items to delete.
75 IMPORT_C void Delete( TInt aIndex, TInt aCount );
80 * Comparison function type; compare two items. Should leave in error.
82 * @param aLeft item to compare to aRight.
83 * @param aRight Item to compare to aLeft.
85 * - negative value, if aLeft is less than aRight;
86 * - 0, if aLeft equals to aRight;
87 * - positive value, if aLeft is greater than aRight.
89 typedef TInt (*ComparisonFuncL)
90 ( const CFavouritesItem& aLeft, const CFavouritesItem& aRight );
93 * Sort the list using bubble-sort.
95 * @param aCompareItemsL Function to be used two elements.
97 IMPORT_C void SortL( ComparisonFuncL aCompareItemsL );
99 public: // Uid <--> array index conversion
102 * Convert Uid to index.
104 * @param aUid Uid to convert.
105 * @return Index for this Uid, or -KErrNotFound if not found.
107 IMPORT_C TInt UidToIndex( TInt aUid ) const;
110 * Convert index to Uid.
112 * @param aIndex Index to convert.
113 * @return Uid for this index, or KFavouritesNullUid if not found.
115 IMPORT_C TInt IndexToUid( TInt aIndex ) const;
118 * Get pointer to item having aUid.
120 * @param aUid Uid of item to look for.
121 * @return Pointer to item having aUid, or NULL if there is no such
122 * item. Item is still owned by the list.
124 IMPORT_C const CFavouritesItem* ItemByUid( TInt aUid ) const;
126 public: // (But not exported:) Streaming
129 * Externalize into a stream.
131 * @param aStream The stream to externalize to.
133 void ExternalizeL( RWriteStream& aStream ) const;
136 * Internalize from a stream. Existing data is kept, new ones appended.
138 * @param aStream The stream to externalize from.
140 void InternalizeL( RReadStream& aStream );