williamr@2: /* williamr@2: * Copyright (c) 2002 Nokia Corporation and/or its subsidiary(-ies). williamr@2: * All rights reserved. williamr@2: * This component and the accompanying materials are made available williamr@2: * under the terms of the License "Eclipse Public License v1.0" williamr@2: * which accompanies this distribution, and is available williamr@2: * at the URL "http://www.eclipse.org/legal/epl-v10.html". williamr@2: * williamr@2: * Initial Contributors: williamr@2: * Nokia Corporation - initial contribution. williamr@2: * williamr@2: * Contributors: williamr@2: * williamr@2: * Description: Declaration of FavouritesItemList williamr@2: * williamr@2: */ williamr@2: williamr@2: williamr@2: #ifndef FAVOURITES_ITEM_LIST_H williamr@2: #define FAVOURITES_ITEM_LIST_H williamr@2: williamr@2: // INCLUDE FILES williamr@2: williamr@2: #include williamr@2: williamr@2: // CONSTANTS williamr@2: williamr@2: // FORWARD DECLARATION williamr@2: williamr@2: class CFavouritesItem; williamr@2: class RWriteStream; williamr@2: class RReadStream; williamr@2: williamr@2: // CLASS DECLARATION williamr@2: williamr@2: /** williamr@2: * CFavouritesItemList is the Array of CFavouritesItem-s. williamr@2: * Items are owned and deleted upon destruction. williamr@2: * Note: using this array downcasted to its base can result in leaks. williamr@2: * Delete method of base class is not virtual! williamr@2: */ williamr@2: class CFavouritesItemList: public CArrayPtrFlat williamr@2: { williamr@2: public: // Constructor and destructor williamr@2: williamr@2: /** williamr@2: * Constructor. williamr@2: * @since 0.9 williamr@2: */ williamr@2: IMPORT_C CFavouritesItemList(); williamr@2: williamr@2: /** williamr@2: * Destructor. Elements are destroyed. williamr@2: * @since 0.9 williamr@2: */ williamr@2: IMPORT_C virtual ~CFavouritesItemList(); williamr@2: williamr@2: public: // new methods williamr@2: williamr@2: /** williamr@2: * Remove and destroy an element. Invalid params will Panic. williamr@2: * @since 0.9 williamr@2: * @param aIndex Index of element to delete. williamr@2: * @return void williamr@2: */ williamr@2: IMPORT_C void Delete( TInt aIndex ); williamr@2: williamr@2: /** williamr@2: * Remove and destroy elements. Invalid params Panic. williamr@2: * @since 0.9 williamr@2: * @param aIndex Index of start element to delete. williamr@2: * @param aCount Number of items to delete. williamr@2: * @return void williamr@2: */ williamr@2: IMPORT_C void Delete( TInt aIndex, TInt aCount ); williamr@2: williamr@2: public: // Sorting williamr@2: williamr@2: /** williamr@2: * Comparison function type; compare two items. Should leave in error. williamr@2: * @since 0.9 williamr@2: * @param aLeft item to compare to aRight. williamr@2: * @param aRight Item to compare to aLeft. williamr@2: * @return williamr@2: * - negative value, if aLeft is less than aRight; williamr@2: * - 0, if aLeft equals to aRight; williamr@2: * - positive value, if aLeft is greater than aRight. williamr@2: */ williamr@2: typedef TInt (*ComparisonFuncL) williamr@2: ( const CFavouritesItem& aLeft, const CFavouritesItem& aRight ); williamr@2: williamr@2: /** williamr@2: * Sort the list using bubble-sort. williamr@2: * @since 0.9 williamr@2: * @param aCompareItemsL Function to be used two elements. williamr@2: */ williamr@2: IMPORT_C void SortL( ComparisonFuncL aCompareItemsL ); williamr@2: williamr@2: public: // Uid <--> array index conversion williamr@2: williamr@2: /** williamr@2: * Convert Uid to index. williamr@2: * @since 0.9 williamr@2: * @param aUid Uid to convert. williamr@2: * @return Index for this Uid, or -KErrNotFound if not found. williamr@2: */ williamr@2: IMPORT_C TInt UidToIndex( TInt aUid ) const; williamr@2: williamr@2: /** williamr@2: * Convert index to Uid. williamr@2: * @since 0.9 williamr@2: * @param aIndex Index to convert. williamr@2: * @return Uid for this index, or KFavouritesNullUid if not found. williamr@2: */ williamr@2: IMPORT_C TInt IndexToUid( TInt aIndex ) const; williamr@2: williamr@2: /** williamr@2: * Get pointer to item having aUid. williamr@2: * @since 0.9 williamr@2: * @param aUid Uid of item to look for. williamr@2: * @return Pointer to item having aUid, or NULL if there is no such williamr@2: * item. Item is still owned by the list. williamr@2: */ williamr@2: IMPORT_C const CFavouritesItem* ItemByUid( TInt aUid ) const; williamr@2: williamr@2: public: // (But not exported:) Streaming williamr@2: williamr@2: /** williamr@2: * Externalize into a stream. williamr@2: * @since 0.9 williamr@2: * @param aStream The stream to externalize to. williamr@2: */ williamr@2: void ExternalizeL( RWriteStream& aStream ) const; williamr@2: williamr@2: /** williamr@2: * Internalize from a stream. Existing data is kept, new ones appended. williamr@2: * @since 0.9 williamr@2: * @param aStream The stream to externalize from. williamr@2: */ williamr@2: void InternalizeL( RReadStream& aStream ); williamr@2: williamr@2: }; williamr@2: williamr@2: #endif williamr@2: williamr@2: // End of file