IMPSengine/datautils/inc/impskey.h
branchRCL_3
changeset 17 a941bc465d9f
parent 0 094583676ce7
equal deleted inserted replaced
16:6ca72c0fe49a 17:a941bc465d9f
       
     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 *     Interface for CImpsKey
       
    16 *
       
    17 */
       
    18 
       
    19 
       
    20 #ifndef IMPS_CIMPSKEY_H
       
    21 #define IMPS_CIMPSKEY_H
       
    22 
       
    23 //  INCLUDES
       
    24 #include "impsdataaccessorapi.h"
       
    25 
       
    26 
       
    27 // DATA TYPES
       
    28 enum TImpsKeyOptions
       
    29     {
       
    30     EPartialKey = 0,
       
    31     EWholeKey,
       
    32     EPartialKeyLonger
       
    33     };
       
    34 
       
    35 // FORWARD DECLARATIONS
       
    36 #ifdef _DEBUG
       
    37 class RFile;
       
    38 #endif
       
    39 
       
    40 // CLASS DECLARATION
       
    41 
       
    42 //
       
    43 // Currently index is limited to 128 possible values.
       
    44 // If this value is exceeded the implementation must be redesigned
       
    45 //
       
    46 
       
    47 /**
       
    48 *  CImpsKey class
       
    49 *  This class is used for identifying different elements
       
    50 */
       
    51 class CImpsKey: public MImpsKey, public CBase
       
    52     {
       
    53     public:  // Constructors and destructor
       
    54 
       
    55         /**
       
    56         * Two-phased constructor.
       
    57         */
       
    58         IMPORT_C static CImpsKey* NewL( );
       
    59 
       
    60         /**
       
    61         * Two-phased constructor.
       
    62         */
       
    63         IMPORT_C static CImpsKey* NewLC( );
       
    64 
       
    65         /**
       
    66         * Destructor.
       
    67         */
       
    68         IMPORT_C virtual ~CImpsKey();
       
    69 
       
    70     public: // New functions
       
    71 
       
    72         /**
       
    73         * Add new elem to the key
       
    74         * @param aElemvalue Element value
       
    75         * @param aKeyType  Key type
       
    76         * @return void
       
    77         */
       
    78         void AddL( const TInt aElemvalue , enum TImpsKeyType aKeyType = EImpsKeyTypeIM );
       
    79 
       
    80         /**
       
    81         * Count the elements in the key
       
    82         * @return TInt Number of elements in key
       
    83         */
       
    84         inline TInt Count( ) const;
       
    85 
       
    86         /**
       
    87         * Pop the last element from the key
       
    88         * If too much is tried the the function leaves
       
    89         * @param aCount how many items to pop. default is 1
       
    90         * @return void
       
    91         */
       
    92         void PopL( TInt aCount = 1 );
       
    93 
       
    94         /**
       
    95         * Get the requested element from the key
       
    96         * @param aIndex Which element
       
    97         * @param aKeyType Return keytype of element
       
    98         * @return TInt
       
    99         */
       
   100         TInt GetElementL( const TInt aIndex, TImpsKeyType& aKeyType ) const;
       
   101 
       
   102         /**
       
   103         * Replaces the last element in the key
       
   104         * @param aElemvalue  New element value
       
   105         * @param aKeyType keytype of element
       
   106         * @return void
       
   107         */
       
   108         void ReplaceLastL( const TInt aElemvalue , enum TImpsKeyType aKeyType = EImpsKeyTypeIM );
       
   109 
       
   110         /**
       
   111         * Resets the key to empty key
       
   112         * @return void
       
   113         */
       
   114         void Reset( );
       
   115 
       
   116         /**
       
   117         * Equal operator
       
   118         * @param aKey to compare with
       
   119         * @return 1 = true, 0 is false
       
   120         */
       
   121         TInt Compare( MImpsKey &aKey );
       
   122 
       
   123         /**
       
   124         * Copy operator
       
   125         * @return copied key
       
   126         */
       
   127         CImpsKey* CopyL( ) const;
       
   128 
       
   129         /**
       
   130         * Check Key
       
   131         * @param aKey Key to be checked
       
   132         * @param aOptions Checking options
       
   133         * @return ETrue if checked ok
       
   134         */
       
   135         TBool CheckKey( const CImpsKey *aKey, TImpsKeyOptions aOptions ) const;
       
   136 
       
   137         /**
       
   138         * Equal operator
       
   139         * @param key to compare with
       
   140         * @return 1 = true, 0 is false
       
   141         */
       
   142         inline TInt operator==( const CImpsKey &aKey ) const;
       
   143 
       
   144         /**
       
   145         * Size
       
   146         * @return size of the key
       
   147         */
       
   148         TInt Size( ) const;
       
   149 
       
   150         /**
       
   151         * Pack
       
   152         * @param start pointer
       
   153         * @return error or KErrNone in success
       
   154         */
       
   155         TInt Pack( const TUint8*& aPtrStart ) const;
       
   156 
       
   157         /**
       
   158         * UnPackL
       
   159         * @param Pointer with stream to unpack
       
   160         */
       
   161         void UnPackL( TUint8*& aPtr );
       
   162 
       
   163         /**
       
   164         * Destructor
       
   165         */
       
   166         void Destroy( );
       
   167 
       
   168 #ifdef _DEBUG
       
   169         /**
       
   170         * DumpToFile
       
   171         * @param file where to dump
       
   172         */
       
   173         void DumpToFileL( RFile& file ) const;
       
   174 #endif
       
   175 
       
   176         /**
       
   177         * SetElementIndex
       
   178         * This function changes last elements index with the given index.
       
   179         * If Key size is 0 then this function doesn't do anything.
       
   180         * @param aCount is which element
       
   181         * @param aNewIndex new index for the element in the key
       
   182         */
       
   183         void SetElementIndex( TInt aCount, TInt aNewIndex );
       
   184 
       
   185     private:
       
   186 
       
   187         /**
       
   188         * By default Symbian OS constructor is private.
       
   189         */
       
   190         CImpsKey();
       
   191 
       
   192         /**
       
   193         * Symbian OS second phase construct
       
   194         */
       
   195         void ConstructL();
       
   196 
       
   197         // By default, prohibit copy constructor
       
   198         CImpsKey( const CImpsKey& );
       
   199         // Prohibit assigment operator
       
   200         CImpsKey& operator= ( const CImpsKey& );
       
   201 
       
   202     private:    // Data
       
   203         HBufC16* iBuffer;
       
   204         TInt    iCount; // Number of items in the buffer
       
   205     };
       
   206 
       
   207 #include "ImpsKey.inl"
       
   208 
       
   209 
       
   210 #endif
       
   211 // End of File