phonebookui/Phonebook2/UIControls/inc/RPbk2ContactBookmarkCollection.h
branchRCL_3
changeset 20 f4a778e096c2
parent 0 e686773b3f54
equal deleted inserted replaced
19:5b6f26637ad3 20:f4a778e096c2
       
     1 /*
       
     2 * Copyright (c) 2006-2007 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:  an implementation of MVPbkContactBookmarkCollection
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #ifndef R_RPBK2CONTACTBOOKMARKCOLLECTION_H
       
    20 #define R_RPBK2CONTACTBOOKMARKCOLLECTION_H
       
    21 
       
    22 #include <e32base.h>
       
    23 #include <MVPbkContactBookmarkCollection.h>
       
    24 #include <MVPbkContactBookmark.h>
       
    25 
       
    26 /**
       
    27  *  A class that implements MVPbkContactBookmarkCollection interface
       
    28  *
       
    29  */
       
    30 class RPbk2ContactBookmarkCollection : public MVPbkContactBookmarkCollection
       
    31     {
       
    32 public:
       
    33     /**
       
    34      * Constructor
       
    35      */
       
    36     RPbk2ContactBookmarkCollection() {}
       
    37 
       
    38     /**
       
    39      * Appends a new bookmark to the collection
       
    40      *
       
    41      * @param aBookmark the new bookmark whose ownership is taken.
       
    42      */
       
    43     inline void AppendL( MVPbkContactBookmark* aBookmark );
       
    44 
       
    45     /**
       
    46      * Frees all resources
       
    47      */
       
    48     inline void Close();
       
    49     
       
    50     /**
       
    51      * Resets the array and deletes all the bookmarks
       
    52      */
       
    53     inline void ResetAndDestroy();
       
    54     
       
    55     /**
       
    56      * This removes all bookmarks from the array and deletes them.
       
    57      * It doesn' free the array memory.
       
    58      */
       
    59     inline void RemoveAndDeleteAll();
       
    60 
       
    61 // from base class MVPbkContactBookmarkCollection
       
    62     inline TInt Count() const;
       
    63     inline const MVPbkContactBookmark& At( TInt aIndex ) const;
       
    64 
       
    65 private: // data
       
    66     /// Own: the bookmarks
       
    67     RPointerArray<MVPbkContactBookmark> iBookmarks;
       
    68     };
       
    69 
       
    70 // INLINE FUNCTIONS
       
    71 inline void RPbk2ContactBookmarkCollection::AppendL(
       
    72         MVPbkContactBookmark* aBookmark )
       
    73     {
       
    74     iBookmarks.AppendL( aBookmark );
       
    75     }
       
    76 
       
    77 inline void RPbk2ContactBookmarkCollection::Close()
       
    78     {
       
    79     iBookmarks.ResetAndDestroy();
       
    80     }
       
    81 
       
    82 inline void RPbk2ContactBookmarkCollection::ResetAndDestroy()
       
    83     {
       
    84     iBookmarks.ResetAndDestroy();
       
    85     }
       
    86 
       
    87 inline void RPbk2ContactBookmarkCollection::RemoveAndDeleteAll()
       
    88     {
       
    89     const TInt count = iBookmarks.Count();
       
    90     for ( TInt i = count - 1; i >= 0; --i )
       
    91         {
       
    92         delete iBookmarks[i];
       
    93         iBookmarks.Remove( i );
       
    94         }
       
    95     }
       
    96 
       
    97 inline TInt RPbk2ContactBookmarkCollection::Count() const
       
    98     {
       
    99     return iBookmarks.Count();
       
   100     }
       
   101 
       
   102 inline const MVPbkContactBookmark& RPbk2ContactBookmarkCollection::At(
       
   103         TInt aIndex ) const
       
   104     {
       
   105     return *iBookmarks[aIndex];
       
   106     }
       
   107 #endif // R_RPBK2CONTACTBOOKMARKCOLLECTION_H