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