sl@0: // Copyright (c) 2004-2009 Nokia Corporation and/or its subsidiary(-ies). sl@0: // All rights reserved. sl@0: // This component and the accompanying materials are made available sl@0: // under the terms of "Eclipse Public License v1.0" sl@0: // which accompanies this distribution, and is available sl@0: // at the URL "http://www.eclipse.org/legal/epl-v10.html". sl@0: // sl@0: // Initial Contributors: sl@0: // Nokia Corporation - initial contribution. sl@0: // sl@0: // Contributors: sl@0: // sl@0: // Description: sl@0: // This file holds the class declarations for the CFbTopMBMCache sl@0: // The cache is used to store the stream ids of bitmaps in a MBM file sl@0: // sl@0: // sl@0: sl@0: #ifndef __FBSMBMC_H__ sl@0: #define __FBSMBMC_H__ sl@0: sl@0: #include sl@0: #include sl@0: #include sl@0: #include "ShiftedFileStore.h" sl@0: sl@0: sl@0: //This class holds the TStreamIds of the bitmaps stored in an MBM file sl@0: //and the filestore of the last loaded bitmap file. The idea of the cache sl@0: //is to speed up loading of bitmaps from a mbm file by skipping the file sl@0: //opening process and mapping the MBM id directly to the Stream ids stored sl@0: //in the cache sl@0: // sl@0: NONSHARABLE_CLASS(CFbTopStreamIdCache): public CBase sl@0: { sl@0: public: sl@0: CFbTopStreamIdCache(TInt aForwardSize, TInt aBackwardSize, TInt aMaxFilestores); sl@0: ~CFbTopStreamIdCache(); sl@0: TStreamId GetStreamIdL(RFile& aFile,const TDesC& aFilename,TInt32 aId,TUint aFileOffset, TInt aSessionHandle); sl@0: TStreamId GetStreamIdL(RFs& aFs,const TDesC& aFilename,TInt32 aId,TUint aFileOffset, TInt aSessionHandle); sl@0: CShiftedFileStore* MruFileStore(); sl@0: void FlushCache(); sl@0: void CloseFileStores(TInt aSessionHandle=0); // If aSessionHandle is not passed, all file stores will be closed sl@0: sl@0: private: sl@0: class RCacheEntry; sl@0: RCacheEntry* AddCacheEntryL(const TDesC& aFilename, TUint aFileOffset); sl@0: RCacheEntry* FindCacheEntry(const TDesC& aFilename, TUint aFileOffset); sl@0: sl@0: private: sl@0: RPointerArray iEntries; // Array of pointers to the cache entries in least-recently-used order sl@0: TUint8* iBuffer; // Buffer for storage of the cache entries sl@0: const TInt iForwardCacheSize; // Max number of cached bitmap ids after the last requested bitmap id sl@0: const TInt iBackwardCacheSize; // Max number of cached bitmap ids before the last requested bitmap id sl@0: const TInt iMaxCacheFilestores; // Max number of filestores in the cache sl@0: sl@0: friend class CTStreamIdCache; // This is used for testing purposes sl@0: }; sl@0: sl@0: sl@0: class CFbTopStreamIdCache::RCacheEntry sl@0: { sl@0: public: sl@0: RCacheEntry(const TDesC& aFilename, TUint aFileOffset); sl@0: TBool SameFile(const TDesC& aFilename, TUint aFileOffset); sl@0: TStreamId GetStreamIdL(TInt32 aId, TInt aForwardSize, TInt aBackwardSize); sl@0: CShiftedFileStore* FileStore(); sl@0: void CloseFileStore(); sl@0: TInt SessionHandle() const; sl@0: void CreateFileStoreL(RFile& aFile, TInt aSessionHandle); sl@0: void CreateFileStoreL(RFs& aFs, const TDesC& aFilename, TInt aSessionHandle); sl@0: public: sl@0: static const TInt KBaseSize; // Size of the class excluding array iStreamIdCache sl@0: sl@0: private: sl@0: TBufC iFilename; // Name of the mbm file sl@0: TUint iFileOffset; // Offset into the mbm file sl@0: CShiftedFileStore *iFilestore; // File store for the mbm file sl@0: TInt iLastId; // Last requested bitmap id from the mbm file sl@0: TInt iStreamIdCount; // Number of stream ids from the mbm file sl@0: TInt iSessionHandle; // Handle to the associated client session sl@0: sl@0: // Keep always iStreamIdCache as the last data member sl@0: // Memory for it is allocated in CFbTopStreamIdCache::AddCacheEntryL() sl@0: TStreamId iStreamIdCache[1]; // Array of stream ids from the mbm file sl@0: sl@0: friend class CTStreamIdCache; // This is used for testing purposes sl@0: }; sl@0: #endif