williamr@2
|
1 |
/*
|
williamr@2
|
2 |
* Copyright (c) 2002 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 "Eclipse Public License v1.0"
|
williamr@2
|
6 |
* which accompanies this distribution, and is available
|
williamr@2
|
7 |
* at the URL "http://www.eclipse.org/legal/epl-v10.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: Declaration of FavouritesItemList
|
williamr@2
|
15 |
*
|
williamr@2
|
16 |
*/
|
williamr@2
|
17 |
|
williamr@2
|
18 |
|
williamr@2
|
19 |
#ifndef FAVOURITES_ITEM_LIST_H
|
williamr@2
|
20 |
#define FAVOURITES_ITEM_LIST_H
|
williamr@2
|
21 |
|
williamr@2
|
22 |
// INCLUDE FILES
|
williamr@2
|
23 |
|
williamr@2
|
24 |
#include <e32base.h>
|
williamr@2
|
25 |
|
williamr@2
|
26 |
// CONSTANTS
|
williamr@2
|
27 |
|
williamr@2
|
28 |
// FORWARD DECLARATION
|
williamr@2
|
29 |
|
williamr@2
|
30 |
class CFavouritesItem;
|
williamr@2
|
31 |
class RWriteStream;
|
williamr@2
|
32 |
class RReadStream;
|
williamr@2
|
33 |
|
williamr@2
|
34 |
// CLASS DECLARATION
|
williamr@2
|
35 |
|
williamr@2
|
36 |
/**
|
williamr@2
|
37 |
* CFavouritesItemList is the Array of CFavouritesItem-s.
|
williamr@2
|
38 |
* Items are owned and deleted upon destruction.
|
williamr@2
|
39 |
* Note: using this array downcasted to its base can result in leaks.
|
williamr@2
|
40 |
* Delete method of base class is not virtual!
|
williamr@2
|
41 |
*/
|
williamr@2
|
42 |
class CFavouritesItemList: public CArrayPtrFlat<CFavouritesItem>
|
williamr@2
|
43 |
{
|
williamr@2
|
44 |
public: // Constructor and destructor
|
williamr@2
|
45 |
|
williamr@2
|
46 |
/**
|
williamr@2
|
47 |
* Constructor.
|
williamr@2
|
48 |
* @since 0.9
|
williamr@2
|
49 |
*/
|
williamr@2
|
50 |
IMPORT_C CFavouritesItemList();
|
williamr@2
|
51 |
|
williamr@2
|
52 |
/**
|
williamr@2
|
53 |
* Destructor. Elements are destroyed.
|
williamr@2
|
54 |
* @since 0.9
|
williamr@2
|
55 |
*/
|
williamr@2
|
56 |
IMPORT_C virtual ~CFavouritesItemList();
|
williamr@2
|
57 |
|
williamr@2
|
58 |
public: // new methods
|
williamr@2
|
59 |
|
williamr@2
|
60 |
/**
|
williamr@2
|
61 |
* Remove and destroy an element. Invalid params will Panic.
|
williamr@2
|
62 |
* @since 0.9
|
williamr@2
|
63 |
* @param aIndex Index of element to delete.
|
williamr@2
|
64 |
* @return void
|
williamr@2
|
65 |
*/
|
williamr@2
|
66 |
IMPORT_C void Delete( TInt aIndex );
|
williamr@2
|
67 |
|
williamr@2
|
68 |
/**
|
williamr@2
|
69 |
* Remove and destroy elements. Invalid params Panic.
|
williamr@2
|
70 |
* @since 0.9
|
williamr@2
|
71 |
* @param aIndex Index of start element to delete.
|
williamr@2
|
72 |
* @param aCount Number of items to delete.
|
williamr@2
|
73 |
* @return void
|
williamr@2
|
74 |
*/
|
williamr@2
|
75 |
IMPORT_C void Delete( TInt aIndex, TInt aCount );
|
williamr@2
|
76 |
|
williamr@2
|
77 |
public: // Sorting
|
williamr@2
|
78 |
|
williamr@2
|
79 |
/**
|
williamr@2
|
80 |
* Comparison function type; compare two items. Should leave in error.
|
williamr@2
|
81 |
* @since 0.9
|
williamr@2
|
82 |
* @param aLeft item to compare to aRight.
|
williamr@2
|
83 |
* @param aRight Item to compare to aLeft.
|
williamr@2
|
84 |
* @return
|
williamr@2
|
85 |
* - negative value, if aLeft is less than aRight;
|
williamr@2
|
86 |
* - 0, if aLeft equals to aRight;
|
williamr@2
|
87 |
* - positive value, if aLeft is greater than aRight.
|
williamr@2
|
88 |
*/
|
williamr@2
|
89 |
typedef TInt (*ComparisonFuncL)
|
williamr@2
|
90 |
( const CFavouritesItem& aLeft, const CFavouritesItem& aRight );
|
williamr@2
|
91 |
|
williamr@2
|
92 |
/**
|
williamr@2
|
93 |
* Sort the list using bubble-sort.
|
williamr@2
|
94 |
* @since 0.9
|
williamr@2
|
95 |
* @param aCompareItemsL Function to be used two elements.
|
williamr@2
|
96 |
*/
|
williamr@2
|
97 |
IMPORT_C void SortL( ComparisonFuncL aCompareItemsL );
|
williamr@2
|
98 |
|
williamr@2
|
99 |
public: // Uid <--> array index conversion
|
williamr@2
|
100 |
|
williamr@2
|
101 |
/**
|
williamr@2
|
102 |
* Convert Uid to index.
|
williamr@2
|
103 |
* @since 0.9
|
williamr@2
|
104 |
* @param aUid Uid to convert.
|
williamr@2
|
105 |
* @return Index for this Uid, or -KErrNotFound if not found.
|
williamr@2
|
106 |
*/
|
williamr@2
|
107 |
IMPORT_C TInt UidToIndex( TInt aUid ) const;
|
williamr@2
|
108 |
|
williamr@2
|
109 |
/**
|
williamr@2
|
110 |
* Convert index to Uid.
|
williamr@2
|
111 |
* @since 0.9
|
williamr@2
|
112 |
* @param aIndex Index to convert.
|
williamr@2
|
113 |
* @return Uid for this index, or KFavouritesNullUid if not found.
|
williamr@2
|
114 |
*/
|
williamr@2
|
115 |
IMPORT_C TInt IndexToUid( TInt aIndex ) const;
|
williamr@2
|
116 |
|
williamr@2
|
117 |
/**
|
williamr@2
|
118 |
* Get pointer to item having aUid.
|
williamr@2
|
119 |
* @since 0.9
|
williamr@2
|
120 |
* @param aUid Uid of item to look for.
|
williamr@2
|
121 |
* @return Pointer to item having aUid, or NULL if there is no such
|
williamr@2
|
122 |
* item. Item is still owned by the list.
|
williamr@2
|
123 |
*/
|
williamr@2
|
124 |
IMPORT_C const CFavouritesItem* ItemByUid( TInt aUid ) const;
|
williamr@2
|
125 |
|
williamr@2
|
126 |
public: // (But not exported:) Streaming
|
williamr@2
|
127 |
|
williamr@2
|
128 |
/**
|
williamr@2
|
129 |
* Externalize into a stream.
|
williamr@2
|
130 |
* @since 0.9
|
williamr@2
|
131 |
* @param aStream The stream to externalize to.
|
williamr@2
|
132 |
*/
|
williamr@2
|
133 |
void ExternalizeL( RWriteStream& aStream ) const;
|
williamr@2
|
134 |
|
williamr@2
|
135 |
/**
|
williamr@2
|
136 |
* Internalize from a stream. Existing data is kept, new ones appended.
|
williamr@2
|
137 |
* @since 0.9
|
williamr@2
|
138 |
* @param aStream The stream to externalize from.
|
williamr@2
|
139 |
*/
|
williamr@2
|
140 |
void InternalizeL( RReadStream& aStream );
|
williamr@2
|
141 |
|
williamr@2
|
142 |
};
|
williamr@2
|
143 |
|
williamr@2
|
144 |
#endif
|
williamr@2
|
145 |
|
williamr@2
|
146 |
// End of file
|