Update contrib.
1 // Copyright (c) 2008-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 the License "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".
8 // Initial Contributors:
9 // Nokia Corporation - initial contribution.
14 // f32\sfat\sl_dir_cache.inl
23 #ifndef SL_DIR_CACHE_INL
24 #define SL_DIR_CACHE_INL
26 #include "sl_dir_cache.h"
29 Get function of TDynamicDirCachePage.
30 @return TInt64 the starting media address of the page content.
32 TInt64 TDynamicDirCachePage::StartPos() const
38 Get function of TDynamicDirCachePage.
39 @return TUint8* the starting ram content of the page content.
41 TUint8* TDynamicDirCachePage::StartPtr() const
47 Set function of TDynamicDirCachePage.
48 @param aPtr starting RAM Ptr that holds the cache page data.
50 void TDynamicDirCachePage::SetStartPtr(TUint8* aPtr)
56 Set function of TDynamicDirCachePage.
57 @param aIsValid boolean value to set validity of the page content.
59 void TDynamicDirCachePage::SetValid(TBool aIsValid)
65 Get function of TDynamicDirCachePage.
66 @return TBool boolean value that indicates validity of the page content.
68 TBool TDynamicDirCachePage::IsValid() const
74 Set function of TDynamicDirCachePage.
75 @param aLocked flag that sets if the page is locked or not.
77 void TDynamicDirCachePage::SetLocked(TBool aLocked)
83 Get function of TDynamicDirCachePage.
84 @return TBool boolean value that indicates if the page is locked.
86 TBool TDynamicDirCachePage::IsLocked() const
92 Set function of TDynamicDirCachePage.
93 @param aType set page type: EUnknown, ELocked, EUnlocked or EActivePage.
95 void TDynamicDirCachePage::SetPageType(TDynamicDirCachePage::TPageType aType)
101 Get function of TDynamicDirCachePage.
102 @return TPageType get page type: EUnknown, ELocked, EUnlocked or EActivePage.
104 TDynamicDirCachePage::TPageType TDynamicDirCachePage::PageType()
110 Get function of TDynamicDirCachePage.
111 @return TUint32 page size in bytes.
113 TUint32 TDynamicDirCachePage::PageSizeInBytes() const
115 return 1 << iOwnerCache->PageSizeInBytesLog2();
119 Deque the page from its queue.
120 @see TDblQueLink::Deque()
122 void TDynamicDirCachePage::Deque()
128 Get function of TDynamicDirCachePage.
129 @return TUint32 page size in segments.
131 TUint32 TDynamicDirCachePage::PageSizeInSegs() const
133 return iOwnerCache->PageSizeInSegs();
137 Interpret the media address into ram address.
138 @param aPos the media address to be interpreted
139 @return TUint8* the ram content pointer that contains that media content.
141 TUint8* TDynamicDirCachePage::PtrInPage(TInt64 aPos) const
143 ASSERT(PosCachedInPage(aPos));
144 return iStartRamAddr + (((TUint32)aPos - (TUint32)iStartMedPos) & (PageSizeInBytes() - 1));
148 Query function, to check if the media address is contained in the page.
149 @param aPos the media address to be queried.
150 @return TBool ETrue if the media address is cached in the page, otherwise EFalse.
152 TBool TDynamicDirCachePage::PosCachedInPage(TInt64 aPos) const
154 return (aPos >= iStartMedPos && aPos < iStartMedPos + PageSizeInBytes());
158 Reset the media address to 0, invalidate page content.
160 void TDynamicDirCachePage::ResetPos()
167 Set page starting media address, invalidate page content.
168 @param aPos the new media address to be set.
170 void TDynamicDirCachePage::SetPos(TInt64 aPos)
178 //========================================================================
180 Calculate the page starting media address, aligned with page size.
181 @param aPos the media address to be aligned.
182 @return TInt64 the aligned media address.
184 TInt64 CDynamicDirCache::CalcPageStartPos(TInt64 aPos) const
186 ASSERT(aPos >= iCacheBasePos);
187 return (((aPos - iCacheBasePos) >> iPageSizeLog2) << iPageSizeLog2) + iCacheBasePos;
191 Check if the cache has reached its limited page number.
192 @return TBool ETrue if cache is full, otherwise EFalse.
194 TBool CDynamicDirCache::CacheIsFull() const
196 // active page, locked page and unlocked page
197 return (iLockedQCount + iUnlockedQCount + 1 >= iMaxSizeInPages);
201 Return the maximum allowed page number of the cache.
203 TUint32 CDynamicDirCache::MaxCacheSizeInPages() const
205 return iMaxSizeInPages;
208 #endif //SL_DIR_CACHE_INL