|
1 // Copyright (c) 2004-2009 Nokia Corporation and/or its subsidiary(-ies). |
|
2 // All rights reserved. |
|
3 // This component and the accompanying materials are made available |
|
4 // under the terms of "Eclipse Public License v1.0" |
|
5 // which accompanies this distribution, and is available |
|
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
7 // |
|
8 // Initial Contributors: |
|
9 // Nokia Corporation - initial contribution. |
|
10 // |
|
11 // Contributors: |
|
12 // |
|
13 // Description: |
|
14 // This file holds the class declarations for the CFbTopMBMCache |
|
15 // The cache is used to store the stream ids of bitmaps in a MBM file |
|
16 // |
|
17 // |
|
18 |
|
19 #ifndef __FBSMBMC_H__ |
|
20 #define __FBSMBMC_H__ |
|
21 |
|
22 #include <e32std.h> |
|
23 #include <e32base.h> |
|
24 #include <s32std.h> |
|
25 #include "ShiftedFileStore.h" |
|
26 |
|
27 |
|
28 //This class holds the TStreamIds of the bitmaps stored in an MBM file |
|
29 //and the filestore of the last loaded bitmap file. The idea of the cache |
|
30 //is to speed up loading of bitmaps from a mbm file by skipping the file |
|
31 //opening process and mapping the MBM id directly to the Stream ids stored |
|
32 //in the cache |
|
33 // |
|
34 NONSHARABLE_CLASS(CFbTopStreamIdCache): public CBase |
|
35 { |
|
36 public: |
|
37 CFbTopStreamIdCache(TInt aForwardSize, TInt aBackwardSize, TInt aMaxFilestores); |
|
38 ~CFbTopStreamIdCache(); |
|
39 TStreamId GetStreamIdL(RFile& aFile,const TDesC& aFilename,TInt32 aId,TUint aFileOffset, TInt aSessionHandle); |
|
40 TStreamId GetStreamIdL(RFs& aFs,const TDesC& aFilename,TInt32 aId,TUint aFileOffset, TInt aSessionHandle); |
|
41 CShiftedFileStore* MruFileStore(); |
|
42 void FlushCache(); |
|
43 void CloseFileStores(TInt aSessionHandle=0); // If aSessionHandle is not passed, all file stores will be closed |
|
44 |
|
45 private: |
|
46 class RCacheEntry; |
|
47 RCacheEntry* AddCacheEntryL(const TDesC& aFilename, TUint aFileOffset); |
|
48 RCacheEntry* FindCacheEntry(const TDesC& aFilename, TUint aFileOffset); |
|
49 |
|
50 private: |
|
51 RPointerArray<RCacheEntry> iEntries; // Array of pointers to the cache entries in least-recently-used order |
|
52 TUint8* iBuffer; // Buffer for storage of the cache entries |
|
53 const TInt iForwardCacheSize; // Max number of cached bitmap ids after the last requested bitmap id |
|
54 const TInt iBackwardCacheSize; // Max number of cached bitmap ids before the last requested bitmap id |
|
55 const TInt iMaxCacheFilestores; // Max number of filestores in the cache |
|
56 |
|
57 friend class CTStreamIdCache; // This is used for testing purposes |
|
58 }; |
|
59 |
|
60 |
|
61 class CFbTopStreamIdCache::RCacheEntry |
|
62 { |
|
63 public: |
|
64 RCacheEntry(const TDesC& aFilename, TUint aFileOffset); |
|
65 TBool SameFile(const TDesC& aFilename, TUint aFileOffset); |
|
66 TStreamId GetStreamIdL(TInt32 aId, TInt aForwardSize, TInt aBackwardSize); |
|
67 CShiftedFileStore* FileStore(); |
|
68 void CloseFileStore(); |
|
69 TInt SessionHandle() const; |
|
70 void CreateFileStoreL(RFile& aFile, TInt aSessionHandle); |
|
71 void CreateFileStoreL(RFs& aFs, const TDesC& aFilename, TInt aSessionHandle); |
|
72 public: |
|
73 static const TInt KBaseSize; // Size of the class excluding array iStreamIdCache |
|
74 |
|
75 private: |
|
76 TBufC<KMaxFileName> iFilename; // Name of the mbm file |
|
77 TUint iFileOffset; // Offset into the mbm file |
|
78 CShiftedFileStore *iFilestore; // File store for the mbm file |
|
79 TInt iLastId; // Last requested bitmap id from the mbm file |
|
80 TInt iStreamIdCount; // Number of stream ids from the mbm file |
|
81 TInt iSessionHandle; // Handle to the associated client session |
|
82 |
|
83 // Keep always iStreamIdCache as the last data member |
|
84 // Memory for it is allocated in CFbTopStreamIdCache::AddCacheEntryL() |
|
85 TStreamId iStreamIdCache[1]; // Array of stream ids from the mbm file |
|
86 |
|
87 friend class CTStreamIdCache; // This is used for testing purposes |
|
88 }; |
|
89 #endif |