diff -r 000000000000 -r e686773b3f54 predictivesearch/PcsAlgorithm/Algorithm1/inc/CPcsCache.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/predictivesearch/PcsAlgorithm/Algorithm1/inc/CPcsCache.h Tue Feb 02 10:12:17 2010 +0200 @@ -0,0 +1,222 @@ +/* +* Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: Used to cache the contacts in memory +* +*/ + +#ifndef __CPCS_CACHE_H__ +#define __CPCS_CACHE_H__ + +// INCLUDE FILES +#include +#include + +#include "CPsData.h" +#include "CPcsKeyMap.h" +#include "CPcsPoolElement.h" +#include "TCacheInfo.h" +#include "CPcsDefs.h" + +// CLASS DECLARATION +class CPcsCache : public CBase +{ + + public: + + /** + * Two phase construction + */ + static CPcsCache* NewL(TDesC& aURI, CPcsKeyMap& aKeyMap, TUint8 aUriId); + + /** + * Virtual destructor + */ + virtual ~CPcsCache(); + + /** + * Returns the database URI this cache support + */ + TDesC& GetURI(); + + /** + * Get CPcsPoolElement for a key id + */ + void GetContactsForKeyL(TInt aKeyId, RPointerArray& aData); + + /** + * Get all cached content + */ + void GetAllContentsL(RPointerArray& aData); + + /** + * Add a data element to the cache + */ + void AddToCacheL(CPsData& aData); + + /** + * Removes a data element from the cache + */ + void RemoveFromCacheL(TInt aItemId); + + /** + * Removes all data elements from the cache + */ + void RemoveAllFromCacheL(); + + /** + * Sets data fields to the cache + */ + void SetDataFields(RArray& aDataFields); + + /** + * Gets data fields from the cache + */ + void GetDataFields(RArray& aDataFields); + + /** + * Updates the caching status for this cache + */ + void UpdateCacheStatus(TInt aStatus); + + /** + * Returns the cache status for this cache + */ + TInt GetCacheStatus(); + + /** + * Returns the UriId + */ + TUint8 GetUriId(); + + /** + * Returns the URI for this cache + */ + HBufC* GetUri(); + /** + * Sets sort order for data fields + */ + void SetSortOrder(RArray& aSortOrder); + + /** + * Gets sort order for data fields + */ + void GetSortOrder(RArray& aSortOrder); + + /** + * Get the index order corresponding to the sort order + */ + void GetIndexOrder(RArray& aIndexOrder); + + /** + * Resort data according to the new sortorder + */ + void ResortdataInPoolsL(); + + private: + + /** + * Constructor + */ + CPcsCache(); + + /** + * Second phase constructor + */ + void ConstructL(TDesC& aURI, CPcsKeyMap& aKeyMap, TUint8 aUriId); + + /** + * Utility function to add a contact to the pool + */ + void AddToPoolL(TInt& aInfo, CPsData& data); + + /** + * Utility function + */ + void SetPoolMap(TInt& aPoolMap, TInt aPoolId); + + /** + * Utility function + */ + TBool GetPoolMap(TInt& aPoolMap, TInt arrayIndex); + + /** + * Utility function + */ + void ComputeIndexOrder(); + private: + + + /* + * Array of key maps + */ + typedef RPointerArray R_PTR_ARRAY; + RPointerArray keyArr; + + /* + * Hashmaps to remember the location of a contact in the pools + */ + RHashMap cacheInfo; + + /* + * Master pool of all contacts in this cache + */ + RPointerArray masterPool; + + /* + * Master pool backup of all contacts in this cache when sortorder changed + */ + RPointerArray masterPoolBackup; + + /* + * Not owned + */ + CPcsKeyMap* keyMap; + + /** + * Owned. Refer to the database URI this cache is for. + */ + HBufC* iURI; + + /** + * Internal URI id for this cache + */ + TInt8 iUriId; + + /** + * Current status of this cache + */ + TInt iCacheStatus; + + /** + * List of data fields (mapped to VPbk ids) supported by this cache + */ + RArray iDataFields; + /** + * Sort order of data fields expected by the clients + */ + RArray iSortOrder; + + /** + * Order of indexes determined by correlating iDataFields and iSortOrder + * Each CPsData data element fields need to be compared in this order + * to get the client expected sort order for this cache. + */ + RArray iIndexOrder; + +}; + + +#endif // __CPCS_CACHE_H__ + +// End of file