predictivesearch/PcsAlgorithm/Algorithm2/inc/CPcsCache.h
branchRCL_3
changeset 85 38bb213f60ba
parent 63 f4a778e096c2
equal deleted inserted replaced
74:6b5524b4f673 85:38bb213f60ba
    36 public:
    36 public:
    37 
    37 
    38     /**
    38     /**
    39      * Two phase construction
    39      * Two phase construction
    40      */
    40      */
    41     static CPcsCache* NewL(CPcsAlgorithm2* aAlgorithm, const TDesC& aURI, 
    41     static CPcsCache* NewL(CPcsAlgorithm2* aAlgorithm, TDesC& aURI, 
    42                            CPcsKeyMap& aKeyMap, TUint8 aUriId);
    42                            CPcsKeyMap& aKeyMap, TUint8 aUriId);
    43 
    43 
    44     /**
    44     /**
    45      * Virtual destructor
    45      * Virtual destructor
    46      */
    46      */
    72     void RemoveFromCacheL(TInt aItemId);
    72     void RemoveFromCacheL(TInt aItemId);
    73 
    73 
    74     /**
    74     /**
    75      * Removes all data elements from the cache
    75      * Removes all data elements from the cache
    76      */
    76      */
    77     void RemoveAllFromCache();
    77     void RemoveAllFromCacheL();
    78 
    78 
    79     /**
    79     /**
    80      * Sets data fields to the cache
    80      * Sets data fields to the cache
    81      */
    81      */
    82     void SetDataFields(RArray<TInt>& aDataFields);
    82     void SetDataFields(RArray<TInt>& aDataFields);
   123     /**
   123     /**
   124      * Resort data according to the new sortorder
   124      * Resort data according to the new sortorder
   125      */
   125      */
   126     void ResortdataInPoolsL();
   126     void ResortdataInPoolsL();
   127 
   127 
   128     /**
       
   129      * Get data index of the first name field
       
   130      */
       
   131     TInt GetFirstNameIndex() const;
       
   132 
       
   133     /**
       
   134      * Get data index of the last name field
       
   135      */
       
   136     TInt GetLastNameIndex() const;
       
   137 
       
   138 private:
   128 private:
   139 
   129 
   140     /**
   130     /**
   141      * Constructor
   131      * Constructor
   142      */
   132      */
   143     CPcsCache();
   133     CPcsCache();
   144 
   134 
   145     /**
   135     /**
   146      * Second phase constructor
   136      * Second phase constructor
   147      */
   137      */
   148     void ConstructL(CPcsAlgorithm2* aAlgorithm, const TDesC& aURI,
   138     void ConstructL(CPcsAlgorithm2* aAlgorithm, TDesC& aURI,
   149                     CPcsKeyMap& aKeyMap, TUint8 aUriId);
   139                     CPcsKeyMap& aKeyMap, TUint8 aUriId);
   150 
   140 
   151     /**
   141     /**
   152      * Utility function to add a contact to the pool
   142      * Utility function to add a contact to the pool
   153      */
   143      */
   154     void AddToPoolL(TUint64& aPoolMap, CPsData& aData);
   144     void AddToPoolL(TInt& aInfo, CPsData& data);
   155 
   145 
   156     /**
   146     /**
   157      * Utility function 
   147      * Utility function 
   158      */
   148      */
   159     void SetPoolMap(TUint64& aPoolMap, TInt aArrayIndex);
   149     void SetPoolMap(TInt& aPoolMap, TInt aPoolId);
   160 
   150 
   161     /**
   151     /**
   162      * Utility function 
   152      * Utility function 
   163      */
   153      */
   164     TBool GetPoolMap(TUint64& aPoolMap, TInt aArrayIndex);
   154     TBool GetPoolMap(TInt& aPoolMap, TInt arrayIndex);
   165 
   155 
   166     /**
       
   167      * Gets all the first characters of the words in the data field according
       
   168      * to which the contact should be inserted into cache.
       
   169      */
       
   170     void GetFirstCharsForDataL( const TDesC& aData, RArray<TChar>& aFirstChars ) const;
       
   171     
       
   172     /**
       
   173      * Gets all the pool IDs matching the given characters. If there are two predictive
       
   174      * keyboards available, then pool IDs are given according to both keyboards.
       
   175      */
       
   176     void GetPoolIdsForCharsL( const RArray<TChar>& aChars, RArray<TInt>& aPoolIds ) const;
       
   177     
       
   178     /**
   156     /**
   179      * Utility function
   157      * Utility function
   180      */
   158      */
   181     void ComputeIndexOrder();
   159     void ComputeIndexOrder();
   182 private:
   160 private:
   185 
   163 
   186     /*
   164     /*
   187      * Array of key maps
   165      * Array of key maps
   188      */
   166      */
   189     typedef RPointerArray<CPcsPoolElement> R_PTR_ARRAY;
   167     typedef RPointerArray<CPcsPoolElement> R_PTR_ARRAY;
   190     RPointerArray<R_PTR_ARRAY> iKeyArr;
   168     RPointerArray<R_PTR_ARRAY> keyArr;
   191 
   169 
   192     /*
   170     /*
   193      * Hashmaps to remember the location of a contact in the pools
   171      * Hashmaps to remember the location of a contact in the pools
   194      */
   172      */
   195     RHashMap<TInt, TUint64> iCacheInfo;
   173     RHashMap<TInt, TInt> cacheInfo;
   196 
   174 
   197     /*
   175     /*
   198      * Master pool of all contacts in this cache
   176      * Master pool of all contacts in this cache
   199      */
   177      */
   200     RPointerArray<CPsData> iMasterPool;
   178     RPointerArray<CPsData> masterPool;
   201     
   179     
   202     /*
   180     /*
   203     * Master pool backup of all contacts in this cache when sortorder changed
   181     * Master pool backup of all contacts in this cache when sortorder changed
   204     */
   182     */
   205     RPointerArray<CPsData> iMasterPoolBackup;
   183     RPointerArray<CPsData> masterPoolBackup;  
   206 
   184 
   207     /*
   185     /*
   208      * Not owned
   186      * Not owned
   209      */
   187      */
   210     CPcsKeyMap* iKeyMap;
   188     CPcsKeyMap* keyMap;
   211 
   189 
   212     /**
   190     /**
   213      * Owned. Refer to the database URI this cache is for.
   191      * Owned. Refer to the database URI this cache is for.
   214      */
   192      */
   215     HBufC* iURI;
   193     HBufC* iURI;