os/graphics/fbs/fontandbitmapserver/inc/FbsRalc.h
author sl@SLION-WIN7.fritz.box
Fri, 15 Jun 2012 03:10:57 +0200
changeset 0 bde4ae8d615e
permissions -rw-r--r--
First public contribution.
     1 // Copyright (c) 2003-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 ROM Address Lookup Cache 
    15 // feature of FBServ: CFbsRalCacheEl, CFbsRalCache.
    16 // 
    17 //
    18 
    19 #ifndef __FBSRALC_H__
    20 #define __FBSRALC_H__
    21 
    22 #include <e32std.h>
    23 #include <e32base.h>
    24 #include <f32file.h>
    25 
    26 /**
    27 This class holds the mapping between the name of a file held in ROM and
    28 the logical address in the memory map that it can be found at. It is used as 
    29 an array element in the circular buffer in the CFbsRalCache object. 
    30 @internalComponent of Font Bitmap Server client library.
    31 */
    32 NONSHARABLE_CLASS(CFbsRalCacheEl) : public CBase
    33 	{
    34 public:	
    35 	CFbsRalCacheEl();
    36 	~CFbsRalCacheEl();
    37 
    38 	static CFbsRalCacheEl* New(const TDesC& aFilename, TAny* aMemAddr);
    39 	static void FreeOnly(CFbsRalCacheEl*& aThisRef);
    40 
    41 	TBool MatchKey(const TDesC& searchKey);
    42 private:
    43 	static TInt ToLower(TInt aInt);
    44 public:
    45 	/** The name of the file held in ROM */
    46 	HBufC*		iFilename;
    47 	/** The logical memory address to that start of the file in ROM */
    48 	TAny*		iAddress;
    49 	/** Counter to track how many lookups are made for this file */
    50 #ifdef _RALC_DEBUG
    51 	TUint iHitCount;
    52 #endif //_RALC_DEBUG
    53 	};
    54 
    55 
    56 /**
    57 This class extends the fixed size circular buffer class to provide a most
    58 recently used cache of filenames to memory addresses for files that are 
    59 held in ROM on the Z: drive. This facility is used in the client side
    60 FBServ library so that ROM bitmaps are loaded as quickly as possible
    61 without IPC to font bitmap server.
    62 The class has been constructed so that its API does not use the Leave
    63 mechanism and so instead it uses return values.
    64 The caching policy used in its implementation is a Most-Recently-Used policy.
    65 @internalComponent of Font Bitmap Server client library.
    66 */
    67 NONSHARABLE_CLASS(CFbsRalCache) : public CCirBuf<CFbsRalCacheEl>
    68 	{
    69 public:
    70 	~CFbsRalCache();
    71 	static CFbsRalCache* New(TInt aCacheSize, RFs& aFs);
    72 
    73 	TAny* Lookup(const TDesC& aFileKey);
    74 
    75 private:
    76 	CFbsRalCache(RFs& aFs);
    77 
    78 	TBool AddItem(const TDesC& aFilename, TAny* aMemAddr);
    79 	void DropItem();
    80 
    81 #ifdef _RALC_DEBUG
    82 	void PrintCache();
    83 #endif//_RALC_DEBUG
    84 
    85 private:
    86 	/** Ref to a File Server session for use by the cache on lookups on 
    87 	a cache miss. */
    88 	RFs& iFs;
    89 
    90 #ifdef _RALC_DEBUG
    91 	TProcessId iProcId;
    92 #endif//_RALC_DEBUG
    93 	};
    94 
    95 
    96 #endif /* __FBSRALC_H__ */