homescreenpluginsrv/inc/hspsdomlist.h
changeset 0 79c6a41cd166
equal deleted inserted replaced
-1:000000000000 0:79c6a41cd166
       
     1 /*
       
     2 * Copyright (c) 2008 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 "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:  List class to hold MhspsDomListItem objects.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 #ifndef hsps_DOM_LIST_H
       
    21 #define hsps_DOM_LIST_H
       
    22 
       
    23 //  INCLUDES
       
    24 #include <e32base.h>
       
    25 #include <s32strm.h>
       
    26 
       
    27 
       
    28 // FORWARD DECLARATIONS
       
    29 class MhspsDomListItem;
       
    30 class ChspsDomStringPool;
       
    31 
       
    32 // CLASS DECLARATION
       
    33 
       
    34 /**
       
    35  *  Represents streamable list object, which holds MhspsDomListItem objects.
       
    36  *
       
    37  *  @lib hspsdomdocument.lib
       
    38  *  @since S60 5.0
       
    39  *  @ingroup group_hspsdom
       
    40  */
       
    41 class ChspsDomList : public CBase
       
    42     {
       
    43     public:
       
    44         enum TListType
       
    45     		{
       
    46     		ENodeList=0,
       
    47     		EAttributeList    		
       
    48     		};
       
    49     public:  // Constructors and destructor
       
    50         
       
    51         /**
       
    52         * Two-phased constructor.
       
    53         */
       
    54         static ChspsDomList* NewL( TListType aListType, ChspsDomStringPool& aStringPool );
       
    55         
       
    56         /**
       
    57         * Two-phased stream constructor.
       
    58         */
       
    59         static ChspsDomList* NewL( 
       
    60             RReadStream& aStream, 
       
    61             ChspsDomStringPool& aStringPool );
       
    62         
       
    63         /**
       
    64         * Destructor.
       
    65         */
       
    66         virtual ~ChspsDomList();
       
    67 
       
    68     public: // Adding and removing
       
    69     	
       
    70     	/**
       
    71         * Frees memory allocated for all items in a list.
       
    72         * 
       
    73         * @since S60 5.0
       
    74         */
       
    75         IMPORT_C void Reset();
       
    76         
       
    77         /**
       
    78         * List owns items.
       
    79         * 
       
    80         * @since S60 5.0
       
    81         * @param aListItem to add.
       
    82         */
       
    83         IMPORT_C void AddItemL( MhspsDomListItem* aListItem );
       
    84 
       
    85         /**
       
    86         * List owns items.
       
    87         * 
       
    88         * @since S60 5.0
       
    89         * @param aListItem to add.
       
    90         * @param aIndex Index in list where the item is added.
       
    91         */
       
    92         IMPORT_C void AddItemL( MhspsDomListItem* aListItem, TInt aIndex );
       
    93         
       
    94         /**
       
    95         * Remove item from list.
       
    96         * 
       
    97         * @since S60 5.0
       
    98         * @param aIndex to aList item to remove.
       
    99         */
       
   100         IMPORT_C void RemoveItem( TInt aIndex );
       
   101         
       
   102         /**
       
   103         * Delete item from list.
       
   104         * 
       
   105         * @since S60 5.0
       
   106         * @param aIndex Item to delete.
       
   107         */
       
   108         IMPORT_C void DeleteItem( TInt aIndex );
       
   109         
       
   110         /**
       
   111         * Remove item from list.
       
   112         * 
       
   113         * @since S60 5.0
       
   114         * @param aItem Item to remove.
       
   115         */
       
   116         IMPORT_C void RemoveItem( MhspsDomListItem* aItem );
       
   117         
       
   118         /**
       
   119         * Delete item from list.
       
   120         * 
       
   121         * @since S60 5.0
       
   122         * @param aItem item to delete.
       
   123         */
       
   124         IMPORT_C void DeleteItem( MhspsDomListItem* aItem );
       
   125    
       
   126    public: // Accessing     
       
   127         /**
       
   128         * List items are accessed by index, i.e like arrays
       
   129         *  
       
   130         * @since S60 5.0
       
   131         * @param aIndex list item index.
       
   132         * @return Pointer to a a list item.
       
   133         */
       
   134         IMPORT_C MhspsDomListItem* Item( TInt aIndex )const;
       
   135         
       
   136         /**
       
   137         * Number of items in a list.
       
   138         * 
       
   139         * @since S60 5.0
       
   140         * @return Item count.
       
   141         */
       
   142         IMPORT_C TInt Length() const;
       
   143         
       
   144         /**
       
   145         * Get the first item in a list.
       
   146         * 
       
   147         * @since S60 5.0
       
   148         * @return Pointer to the first item in a list.
       
   149         */
       
   150         IMPORT_C MhspsDomListItem* First();
       
   151         
       
   152         /**
       
   153         * The last item in a list
       
   154         * 
       
   155         * @since S60 5.0
       
   156         * @return Pointer to the last item in a list.
       
   157         */
       
   158         IMPORT_C MhspsDomListItem* Last();
       
   159         
       
   160         /**
       
   161         * Find list item by item name. Searches list items 
       
   162         * which have name attribute.
       
   163         * 
       
   164         * @since S60 5.0
       
   165         * @param aName UTF8 encoded item's name to be searched
       
   166         * @return Pointer to the list item, NULL if not exist.
       
   167         */
       
   168         IMPORT_C MhspsDomListItem* FindByName( const TDesC8& aName );
       
   169         
       
   170         /**
       
   171         * Get item index
       
   172         * 
       
   173         * @since S60 5.0
       
   174         * @param aItem Item to be searched.
       
   175         * @return Item index or KErrNotFound if not found.
       
   176         */
       
   177         IMPORT_C TInt ItemIndex( const MhspsDomListItem& aItem )const;
       
   178         
       
   179         /**
       
   180         * Get reference to the dom's string pool.
       
   181         * 
       
   182         * @since S60 5.0
       
   183         * @return Reference to string pool.
       
   184         */
       
   185         IMPORT_C ChspsDomStringPool& StringPool() const;
       
   186         
       
   187         /**
       
   188         * Count items in a list.
       
   189         */
       
   190         TInt Count() const;
       
   191   public: // Serializing      
       
   192         
       
   193         /**
       
   194         * Get list's data size in bytes.
       
   195         * @since Series 60 3.1
       
   196         * @return Data size in bytes
       
   197         */
       
   198         TInt Size() const;
       
   199     
       
   200         /**
       
   201         * Externalize list's data.
       
   202         * @since Series 60 3.1
       
   203         * @param aStream Output stream
       
   204         */
       
   205         void ExternalizeL( RWriteStream& aStream ) const;
       
   206         
       
   207         /**
       
   208         * Internalize list's data.
       
   209         * @since Series 60 3.1
       
   210         * @param aStream Input stream
       
   211         */
       
   212         void InternalizeL( RReadStream& aStream );
       
   213         
       
   214    public: //Utility
       
   215    	   		
       
   216    		/**
       
   217         * Get list item type.
       
   218         * @since Series 60 3.1
       
   219         * @return List item type
       
   220         */
       
   221         TListType Type() const 
       
   222             {
       
   223             return iListType;
       
   224             }
       
   225             
       
   226         
       
   227    private:
       
   228 
       
   229         /**
       
   230         * C++ default constructor.
       
   231         */
       
   232         ChspsDomList( TListType aListType, ChspsDomStringPool& aStringPool );
       
   233         
       
   234         /**
       
   235         * By default Symbian 2nd phase constructor is private.
       
   236         */
       
   237         void ConstructL();
       
   238         
       
   239     protected:
       
   240         //List type    	
       
   241     	TListType                       iListType;
       
   242         
       
   243         //Items are stored into a segmented array
       
   244         RPointerArray<MhspsDomListItem>   iList;
       
   245     
       
   246     private:    // Data
       
   247         // StringPool, not owned
       
   248         ChspsDomStringPool&   iStringPool;
       
   249         
       
   250         
       
   251     };
       
   252 
       
   253 #endif      // hsps_DOM_LIST_H  
       
   254             
       
   255 // End of File