ncdengine/provider/server/inc/ncddbmaxsizemap.h
changeset 0 ba25891c3a9e
equal deleted inserted replaced
-1:000000000000 0:ba25891c3a9e
       
     1 /*
       
     2 * Copyright (c) 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:   Contains CNcdDbMaxSizeMap class
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #ifndef NCD_DB_MAX_SIZE_MAP
       
    20 #define NCD_DB_MAX_SIZE_MAP
       
    21 
       
    22 /**
       
    23  * This class object acts as a map that has the client uid as the key
       
    24  * and the db byte size as the value.
       
    25  */
       
    26 
       
    27 #include <e32base.h>
       
    28 #include <e32cmn.h>
       
    29 
       
    30 class CNcdDbMaxSizeMap : public CBase
       
    31     {
       
    32     
       
    33 public:
       
    34 
       
    35     /** 
       
    36      * @param aDefaultMaxSize
       
    37      * @return CNcdDbMaxSizeMap* Pointer to the created object 
       
    38      * of this class.
       
    39      */
       
    40     static CNcdDbMaxSizeMap* NewL( const TInt aDefaultMaxSize );
       
    41 
       
    42     /** 
       
    43      * @param aDefaultMaxSize
       
    44      * @return CNcdDbMaxSizeMap* Pointer to the created object 
       
    45      * of this class.
       
    46      */
       
    47     static CNcdDbMaxSizeMap* NewLC( const TInt aDefaultMaxSize );
       
    48 
       
    49 
       
    50     /**
       
    51      * Destructor
       
    52      */
       
    53     virtual ~CNcdDbMaxSizeMap();
       
    54 
       
    55 
       
    56     /**
       
    57      * Sets the value that corresponds to the given key.
       
    58      * If the key already exists. Then the corresponding value
       
    59      * will be reset. If the key does not exist. Then the new
       
    60      * key value pair is created.
       
    61      *
       
    62      * @return KErrNone if value was set. Else some system error.
       
    63      */
       
    64     TInt SetValue( const TUid& aKey,
       
    65                    TInt aValue );
       
    66     
       
    67 
       
    68     /**
       
    69      * @return TInt the value that corresponds the given key.
       
    70      * If the value corresponding the key was not found from the
       
    71      * map, then the default value given for the constructor is 
       
    72      * returned.
       
    73      */                   
       
    74     TInt Value( const TUid& aKey ) const;
       
    75     
       
    76     
       
    77 protected:
       
    78 
       
    79     /** 
       
    80      * Constructor
       
    81      *
       
    82      * @param aDefaultMaxSize
       
    83      */ 
       
    84     CNcdDbMaxSizeMap( const TInt aDefaultMaxSize );
       
    85     
       
    86     
       
    87     /**
       
    88      * ConstructL
       
    89      */
       
    90     virtual void ConstructL();
       
    91 
       
    92             
       
    93 private:
       
    94     
       
    95     // Prevent these if not implemented
       
    96     CNcdDbMaxSizeMap( const CNcdDbMaxSizeMap& aObject );
       
    97     CNcdDbMaxSizeMap& operator =( const CNcdDbMaxSizeMap& aObject );
       
    98 
       
    99 
       
   100     // Searches for the given key. And returns the index of that key.
       
   101     // Returns KElementWasNotFound if the key was not found.
       
   102     TInt KeyIndex( const TUid& aKey ) const;
       
   103 
       
   104 
       
   105 private: // data
       
   106 
       
   107     // Constant value that is used if the search for the key or value
       
   108     // did not find any actual value.
       
   109     const TInt KElementWasNotFound;
       
   110 
       
   111     // The default max size that is used if the key is not found
       
   112     // and some value should be returned.
       
   113     const TInt iDefaultMaxSize;
       
   114 
       
   115 
       
   116     // The key can not be changed
       
   117     RArray<const TUid> iKeyArray;
       
   118     
       
   119     // The value of may be changed.
       
   120     RArray<TInt> iValueArray;
       
   121 
       
   122     };
       
   123     
       
   124 #endif // NCD_DB_MAX_SIZE_MAP