phonebookui/Phonebook/inc/CPbkContactIdSet.h
changeset 0 e686773b3f54
equal deleted inserted replaced
-1:000000000000 0:e686773b3f54
       
     1 /*
       
     2 * Copyright (c) 2002 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 *     Set data structure for contact model contact IDs.
       
    16 *
       
    17 */
       
    18 
       
    19 
       
    20 #ifndef __CPbkContactIdSet_H__
       
    21 #define __CPbkContactIdSet_H__
       
    22 
       
    23 //  INCLUDES
       
    24 #include <cntdef.h>
       
    25 
       
    26 // CLASS DECLARATION
       
    27 
       
    28 /**
       
    29  * @internal Only Phonebook internal use supported!
       
    30  *
       
    31  * Data structure for Contact model Contact IDs.
       
    32  */
       
    33 class CPbkContactIdSet : public CBase
       
    34 	{
       
    35     public: // Interface
       
    36         /**
       
    37          * Constructor.
       
    38          */
       
    39 	    IMPORT_C static CPbkContactIdSet* NewL();
       
    40 
       
    41         /**
       
    42          * Constructor.
       
    43          */
       
    44 	    IMPORT_C static CPbkContactIdSet* NewLC();
       
    45 
       
    46         /**
       
    47          * Constructor. Copies the contents of this set from aSet.
       
    48          */
       
    49 	    IMPORT_C static CPbkContactIdSet* NewL(const CPbkContactIdSet& aSet);
       
    50 
       
    51         /**
       
    52          * Constructor. Copies the contents of this set from aSet.
       
    53          */
       
    54 	    IMPORT_C static CPbkContactIdSet* NewLC(const CPbkContactIdSet& aSet);
       
    55 
       
    56         /**
       
    57          * Constructor. Copies the contents of this set from aArray.
       
    58          */
       
    59         IMPORT_C static CPbkContactIdSet* NewL(const CContactIdArray& aArray);
       
    60 
       
    61         /**
       
    62          * Constructor. Copies the contents of this set from aArray.
       
    63          */
       
    64         IMPORT_C static CPbkContactIdSet* NewLC(const CContactIdArray& aArray);
       
    65 
       
    66         /**
       
    67          * Destructor.
       
    68          */
       
    69 	    ~CPbkContactIdSet();
       
    70 
       
    71         /**
       
    72          * Returns TContactItemId at aIndex in this set.
       
    73          */
       
    74 	    inline TContactItemId operator[](TInt aIndex) const;
       
    75 
       
    76         /**
       
    77          * Returns number of Ids in the set.
       
    78          */
       
    79 	    inline TInt Count() const;
       
    80 
       
    81         /**
       
    82          * Removes all items from this set.
       
    83          */
       
    84 	    inline void Reset();
       
    85 
       
    86         /**
       
    87          * Searches for aId from this set, returns ETrue if found.
       
    88          */
       
    89 	    IMPORT_C TBool Find(TContactItemId aId) const;
       
    90 
       
    91         /**
       
    92          * Adds aId to this set.
       
    93          *
       
    94          * @exception KErrNoMemory  if this function leaves this set is not 
       
    95          *                          modified.
       
    96          * @postcond Find(aId) && Count() == old(Count()+1)
       
    97          */
       
    98 	    IMPORT_C void AddL(TContactItemId aId);
       
    99 
       
   100         /**
       
   101          * Adds all Ids in aSet to this set.
       
   102          *
       
   103          * @exception KErrNoMemory  if this function leaves none of the Ids in 
       
   104          *                          aSet are added to this set.
       
   105          * @postcond for all Ids i in aSet: Find(i)==ETrue
       
   106          */
       
   107 	    IMPORT_C void AddL(const CPbkContactIdSet& aSet);
       
   108 
       
   109         /**
       
   110          * Adds all Ids in aArray to this set.
       
   111          *
       
   112          * @exception KErrNoMemory  if this function leaves none of the Ids in 
       
   113          *                          aArray are added to this set.
       
   114          * @postcond for all Ids i in aArray: Find(i)==ETrue
       
   115          */
       
   116 	    IMPORT_C void AddL(const CContactIdArray& aArray);
       
   117 
       
   118         /**
       
   119          * Removes aId from this set.
       
   120          */
       
   121 	    IMPORT_C void Remove(TContactItemId aId);
       
   122 
       
   123         /**
       
   124          * Removes all Ids in aArray from this set.
       
   125          */
       
   126 	    IMPORT_C void Remove(const CContactIdArray& aArray);
       
   127 
       
   128         /**
       
   129          * Removes all Ids in aSet from this set.
       
   130          */
       
   131         IMPORT_C void Remove(const CPbkContactIdSet& aSet);
       
   132 
       
   133         /**
       
   134          * Creates a CContactIdArray copy of this set's contents.
       
   135          *
       
   136          * @return  new CContactIdArray containing all contact Ids in this set.
       
   137          *          Caller is responsible of the returned array.
       
   138          */
       
   139         IMPORT_C CContactIdArray* GetContactIdArrayL() const;
       
   140 
       
   141         __DECLARE_TEST;
       
   142 
       
   143     private: // Implementation
       
   144 	    CPbkContactIdSet();
       
   145         
       
   146     private: // Data
       
   147         /// Own: sorted array of contact Ids.
       
   148 	    RArray<TInt> iIds;
       
   149 	};
       
   150 
       
   151 inline TContactItemId CPbkContactIdSet::operator[](TInt aIndex) const
       
   152     {
       
   153     // iIds checks aIndex
       
   154     return iIds[aIndex];
       
   155     }
       
   156 
       
   157 inline TInt CPbkContactIdSet::Count() const
       
   158     {
       
   159     return iIds.Count();
       
   160     }
       
   161 
       
   162 inline void CPbkContactIdSet::Reset()
       
   163     {
       
   164     iIds.Reset();
       
   165     }
       
   166 
       
   167 
       
   168 #endif // __CPbkContactIdSet_H__
       
   169 
       
   170 // End of File