mmserv/radioutility/presetutility/inc/cenrepbookkeeping.h
changeset 14 80975da52420
equal deleted inserted replaced
12:5a06f39ad45b 14:80975da52420
       
     1 /*
       
     2 * Copyright (c) 2009 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:  This is a class, responsible of keeping track of existing presets
       
    15 *               and their indexes.
       
    16 *
       
    17 *
       
    18 */
       
    19 
       
    20 #ifndef CCENREPBOOKKEEPING_H_
       
    21 #define CCENREPBOOKKEEPING_H_
       
    22 
       
    23 #include <e32base.h>
       
    24 
       
    25 class RWriteStream;
       
    26 class RReadStream;
       
    27 
       
    28 const TInt KMaxNumberOfPresetStations = 100;  // One temporarily used for internal book keeping
       
    29 
       
    30 #define  LENGTHOFUSEDINDEXLWORDSARRAY ((KMaxNumberOfPresetStations/32) + 1)
       
    31 /**
       
    32  *  it is a class, responsible of keeping track of existing presets and their indexes.
       
    33  */
       
    34 NONSHARABLE_CLASS( CCenrepBookKeeping ) : public CBase
       
    35 {
       
    36 public:
       
    37 
       
    38     /**
       
    39     * Default class constructor.
       
    40     */
       
    41     CCenrepBookKeeping();
       
    42 
       
    43     /**
       
    44     * Destructor of CCenrepBookKeeping class.
       
    45     */
       
    46     ~CCenrepBookKeeping();
       
    47 
       
    48     /**
       
    49     * Get the current number of presets.
       
    50     * @return The number of presets.
       
    51     */
       
    52     TInt PresetCount() const;
       
    53 
       
    54     /**
       
    55     * Get the index of first preset.
       
    56     * @return The first preset index.
       
    57     */        
       
    58     TInt FirstIndex() const;
       
    59 
       
    60     /**
       
    61     * Get the index of the next preset.
       
    62     * @param aFromIndex -  Start from index after this.
       
    63     * @return the next preset index.
       
    64     */           
       
    65     TInt NextIndex( TInt aFromIndex = 0 );
       
    66 
       
    67     /**
       
    68     * Find an unused preset index.
       
    69     * @return Allocated index.
       
    70     */           
       
    71     TInt FindUnusedIndex() const;
       
    72     
       
    73     /**
       
    74     * Check if given index is used.
       
    75     * @return ETrue if used, otherwise EFalse 
       
    76     */           
       
    77     TBool IsIndexUsed( const TInt aIndex );
       
    78 
       
    79     /**
       
    80     * Add a preset.
       
    81     * @param aIndex -  Proposed index.
       
    82     * @return Used/Allocated index.
       
    83     */           
       
    84     void AddIndex( const TInt aIndex );
       
    85 
       
    86     /**
       
    87     * Remove a preset.
       
    88     * @param aIndex -  Index of the preset to be removed.
       
    89     * @return Used/Allocated index.
       
    90     */           
       
    91     void RemoveIndex( const TInt aIndex );
       
    92 
       
    93     /**
       
    94     * Clear all data.
       
    95     * @return The first preset index.
       
    96     */
       
    97     void Clear();
       
    98     
       
    99     /**
       
   100     * Gives descriptor pointer to bookkeeping's data.
       
   101     * @return TPtr8 Descriptor that contains bookkeeping data.
       
   102     */
       
   103     TPtr8 BookKeepingData();
       
   104 
       
   105 private:
       
   106 
       
   107     // This data is copied to Central Repository Key (buffer) as such without
       
   108     // actual serialization.
       
   109     // Therefore in order to keep backward incombatibility don't
       
   110     // change the order of fields. Only the last array field can be allowed to grow.
       
   111     // If a new field is added to the end, the preceding array field cannot grow anymore.
       
   112     // Additionally the size of this structure should never shrink.
       
   113     class TBookKeepingData 
       
   114     {
       
   115     public:
       
   116         TInt iCount;    
       
   117         TUint32 iUsedIndexLWords[ LENGTHOFUSEDINDEXLWORDSARRAY ];
       
   118     } iBookKeepingData;
       
   119 
       
   120 };
       
   121 
       
   122 #endif // CCENREPBOOKKEEPING_H_