userlibandfileserver/fileserver/sfat32/sl_cache.h
changeset 33 0173bcd7697c
parent 15 4122176ea935
child 62 4a8fed1c0ef6
equal deleted inserted replaced
31:56f325a607ea 33:0173bcd7697c
   146 class CMediaWTCache : public CBase, public MWTCacheInterface
   146 class CMediaWTCache : public CBase, public MWTCacheInterface
   147     {
   147     {
   148 public:
   148 public:
   149         ~CMediaWTCache();
   149         ~CMediaWTCache();
   150         
   150         
   151         static CMediaWTCache* NewL(TFatDriveInterface& aDrive, TUint32 aNumPages, TUint32 aPageSizeLog2);
   151         static CMediaWTCache* NewL(TDriveInterface& aDrive, TUint32 aNumPages, TUint32 aPageSizeLog2);
   152 
   152 
   153         void ConstructL(TUint32 aNumPages, TUint32 aPageSizeLog2);
   153         void ConstructL(TUint32 aNumPages, TUint32 aPageSizeLog2);
   154         
   154         
   155         //-- overloads from the base class
   155         //-- overloads from the base class
   156         void    ReadL (TInt64 aPos,TInt aLength,TDes8& aDes);
   156         void    ReadL (TInt64 aPos,TInt aLength,TDes8& aDes);
   167         inline void SetCacheBasePos(TInt64 aBasePos);
   167         inline void SetCacheBasePos(TInt64 aBasePos);
   168         //--
   168         //--
   169         
   169         
   170 protected:
   170 protected:
   171         CMediaWTCache();
   171         CMediaWTCache();
   172         CMediaWTCache(TFatDriveInterface& aDrive);
   172         CMediaWTCache(TDriveInterface& aDrive);
   173         
   173         
   174         inline TInt64  CalcPageStartPos(TInt64 aPos) const;
   174         inline TInt64  CalcPageStartPos(TInt64 aPos) const;
   175         inline TUint32 PageSize() const;
   175         inline TUint32 PageSize() const;
   176         
   176         
   177         void MakePageLRU(TInt aPageNo);
   177         void MakePageLRU(TInt aPageNo);
   180         TUint32 GrabPage() const;
   180         TUint32 GrabPage() const;
   181         TUint32 GrabReadPageL(TInt64 aPos);
   181         TUint32 GrabReadPageL(TInt64 aPos);
   182         TUint32 FindOrGrabReadPageL(TInt64 aPos);
   182         TUint32 FindOrGrabReadPageL(TInt64 aPos);
   183         
   183         
   184 protected:
   184 protected:
   185         TFatDriveInterface& iDrive;        ///< reference to the driver for media access
   185         TDriveInterface& iDrive;        ///< reference to the driver for media access
   186         TUint32             iPageSizeLog2; ///< Log2 (cache page size)
   186         TUint32             iPageSizeLog2; ///< Log2 (cache page size)
   187         mutable TBool       iAllPagesValid;///< ETrue if all cache pages have valid data
   187         mutable TBool       iAllPagesValid;///< ETrue if all cache pages have valid data
   188         TInt64              iCacheBasePos; ///< Cache pages base position, used to align them at cluster size
   188         TInt64              iCacheBasePos; ///< Cache pages base position, used to align them at cluster size
   189         RPointerArray<CWTCachePage> iPages; ///< array of pointers to the cache pages. Used for organising LRU list
   189         RPointerArray<CWTCachePage> iPages; ///< array of pointers to the cache pages. Used for organising LRU list
   190         TUint32             iCacheDisabled :1; ///< if not 0 the cache is disabled totally and all reads and writes go via TFatDriveInterface directly
   190         TUint32             iCacheDisabled :1; ///< if not 0 the cache is disabled totally and all reads and writes go via TDriveInterface directly
   191     };
   191     };
   192 
   192 
   193 
   193 
   194 
   194 
   195 
   195