idlefw/inc/utility/caicontentitemarrayiterator.h
changeset 0 79c6a41cd166
equal deleted inserted replaced
-1:000000000000 0:79c6a41cd166
       
     1 /*
       
     2 * Copyright (c) 2005-2006 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:  
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 #ifndef C_AIARRAYITERATOR_H
       
    21 #define C_AIARRAYITERATOR_H
       
    22 
       
    23 
       
    24 #include <e32base.h>
       
    25 #include <aicontentmodel.h>
       
    26 
       
    27 /**
       
    28  *  @ingroup group_aiutils
       
    29  * 
       
    30  *  Content item array iterator.
       
    31  *
       
    32  *  Iterator implementation for content item arrays
       
    33  *  Usage example:
       
    34  *
       
    35  *      const TAiContentItem KExPluginContent[] =
       
    36  *          {
       
    37  *              { 1, "Counter", "text/plain" },
       
    38  *              { 2, "Status",  "text/plain" }
       
    39  *          };
       
    40  *
       
    41  *      CAiContentItemArrayIterator* iContent =
       
    42  *          CreateIteratorL( KExPluginContent );
       
    43  *
       
    44  *      while( iContent->HasNext() )
       
    45  *          {
       
    46  *          TAiContentItem& myItem = iContent->NextL();
       
    47  *          // My ops using myItem
       
    48  *          }
       
    49  *
       
    50  *  @since S60 3.1
       
    51  */
       
    52 NONSHARABLE_CLASS(CAiContentItemArrayIterator) : 
       
    53     public CBase, public MAiContentItemIterator
       
    54     {
       
    55 public:
       
    56     
       
    57     /**
       
    58      * Creates a new iterator instance from a TAiContentItem array.
       
    59      *
       
    60      * @param aArray content item array.
       
    61      * @param aCount  number of content items in aArray.
       
    62      * @return a new iterator object for aArray.
       
    63      * @see CreateIteratorL
       
    64      * @since S60 3.2
       
    65      */
       
    66     static CAiContentItemArrayIterator* NewL
       
    67         ( const TAiContentItem* aArray, TInt aCount );
       
    68         
       
    69     virtual ~CAiContentItemArrayIterator();
       
    70     
       
    71     void Release();
       
    72 
       
    73 // from base class MAiContentItemIterator
       
    74 
       
    75     TBool HasNext() const;
       
    76 
       
    77     const TAiContentItem& NextL();
       
    78 
       
    79     const TAiContentItem& ItemL(TInt aId) const;
       
    80     
       
    81 	const TAiContentItem& ItemL( const TDesC& aCid ) const;
       
    82 
       
    83     void Reset();
       
    84 
       
    85 private:
       
    86 
       
    87      CAiContentItemArrayIterator( const TAiContentItem* aArray, TInt aCount );
       
    88 
       
    89 private: // data
       
    90 
       
    91     /**
       
    92      * Array of items
       
    93      * Not Own.
       
    94      */
       
    95     const TAiContentItem*   iArray;
       
    96 
       
    97     /**
       
    98      * Total number of items
       
    99      */
       
   100     TInt                    iCount;
       
   101 
       
   102     /**
       
   103      * Current iterator index
       
   104      */
       
   105     TInt                    iIndex;
       
   106     };
       
   107 
       
   108 
       
   109 #endif // C_CAiContentItemArrayIterator_H