1 favouritesitemlist.h |
1 /* |
|
2 * Copyright (c) 2002 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 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". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: Declaration of FavouritesItemList |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #ifndef FAVOURITES_ITEM_LIST_H |
|
20 #define FAVOURITES_ITEM_LIST_H |
|
21 |
|
22 // INCLUDE FILES |
|
23 |
|
24 #include <e32base.h> |
|
25 |
|
26 // CONSTANTS |
|
27 |
|
28 // FORWARD DECLARATION |
|
29 |
|
30 class CFavouritesItem; |
|
31 class RWriteStream; |
|
32 class RReadStream; |
|
33 |
|
34 // CLASS DECLARATION |
|
35 |
|
36 /** |
|
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! |
|
41 */ |
|
42 class CFavouritesItemList: public CArrayPtrFlat<CFavouritesItem> |
|
43 { |
|
44 public: // Constructor and destructor |
|
45 |
|
46 /** |
|
47 * Constructor. |
|
48 * @since 0.9 |
|
49 */ |
|
50 IMPORT_C CFavouritesItemList(); |
|
51 |
|
52 /** |
|
53 * Destructor. Elements are destroyed. |
|
54 * @since 0.9 |
|
55 */ |
|
56 IMPORT_C virtual ~CFavouritesItemList(); |
|
57 |
|
58 public: // new methods |
|
59 |
|
60 /** |
|
61 * Remove and destroy an element. Invalid params will Panic. |
|
62 * @since 0.9 |
|
63 * @param aIndex Index of element to delete. |
|
64 * @return void |
|
65 */ |
|
66 IMPORT_C void Delete( TInt aIndex ); |
|
67 |
|
68 /** |
|
69 * Remove and destroy elements. Invalid params Panic. |
|
70 * @since 0.9 |
|
71 * @param aIndex Index of start element to delete. |
|
72 * @param aCount Number of items to delete. |
|
73 * @return void |
|
74 */ |
|
75 IMPORT_C void Delete( TInt aIndex, TInt aCount ); |
|
76 |
|
77 public: // Sorting |
|
78 |
|
79 /** |
|
80 * Comparison function type; compare two items. Should leave in error. |
|
81 * @since 0.9 |
|
82 * @param aLeft item to compare to aRight. |
|
83 * @param aRight Item to compare to aLeft. |
|
84 * @return |
|
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. |
|
88 */ |
|
89 typedef TInt (*ComparisonFuncL) |
|
90 ( const CFavouritesItem& aLeft, const CFavouritesItem& aRight ); |
|
91 |
|
92 /** |
|
93 * Sort the list using bubble-sort. |
|
94 * @since 0.9 |
|
95 * @param aCompareItemsL Function to be used two elements. |
|
96 */ |
|
97 IMPORT_C void SortL( ComparisonFuncL aCompareItemsL ); |
|
98 |
|
99 public: // Uid <--> array index conversion |
|
100 |
|
101 /** |
|
102 * Convert Uid to index. |
|
103 * @since 0.9 |
|
104 * @param aUid Uid to convert. |
|
105 * @return Index for this Uid, or -KErrNotFound if not found. |
|
106 */ |
|
107 IMPORT_C TInt UidToIndex( TInt aUid ) const; |
|
108 |
|
109 /** |
|
110 * Convert index to Uid. |
|
111 * @since 0.9 |
|
112 * @param aIndex Index to convert. |
|
113 * @return Uid for this index, or KFavouritesNullUid if not found. |
|
114 */ |
|
115 IMPORT_C TInt IndexToUid( TInt aIndex ) const; |
|
116 |
|
117 /** |
|
118 * Get pointer to item having aUid. |
|
119 * @since 0.9 |
|
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. |
|
123 */ |
|
124 IMPORT_C const CFavouritesItem* ItemByUid( TInt aUid ) const; |
|
125 |
|
126 public: // (But not exported:) Streaming |
|
127 |
|
128 /** |
|
129 * Externalize into a stream. |
|
130 * @since 0.9 |
|
131 * @param aStream The stream to externalize to. |
|
132 */ |
|
133 void ExternalizeL( RWriteStream& aStream ) const; |
|
134 |
|
135 /** |
|
136 * Internalize from a stream. Existing data is kept, new ones appended. |
|
137 * @since 0.9 |
|
138 * @param aStream The stream to externalize from. |
|
139 */ |
|
140 void InternalizeL( RReadStream& aStream ); |
|
141 |
|
142 }; |
|
143 |
|
144 #endif |
|
145 |
|
146 // End of file |