sl@0
|
1 |
// Copyright (c) 2008-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 the License "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 |
// f32\sfat32\inc\sl_leafdir_cache.h
|
sl@0
|
15 |
//
|
sl@0
|
16 |
//
|
sl@0
|
17 |
|
sl@0
|
18 |
/**
|
sl@0
|
19 |
@file
|
sl@0
|
20 |
@internalTechnology
|
sl@0
|
21 |
*/
|
sl@0
|
22 |
|
sl@0
|
23 |
//!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
sl@0
|
24 |
//!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
sl@0
|
25 |
//!!
|
sl@0
|
26 |
//!! WARNING!! DO NOT edit this file !! '\sfat' component is obsolete and is not being used. '\sfat32'replaces it
|
sl@0
|
27 |
//!!
|
sl@0
|
28 |
//!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
sl@0
|
29 |
//!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
sl@0
|
30 |
|
sl@0
|
31 |
|
sl@0
|
32 |
#ifndef SL_LEAFDIR_CACHE_H
|
sl@0
|
33 |
#define SL_LEAFDIR_CACHE_H
|
sl@0
|
34 |
|
sl@0
|
35 |
//---------------------------------------------------------------------------------------------------------------------------------
|
sl@0
|
36 |
|
sl@0
|
37 |
class CLeafDirTree;
|
sl@0
|
38 |
|
sl@0
|
39 |
/*
|
sl@0
|
40 |
A data structure to define the location of a direcotry
|
sl@0
|
41 |
*/
|
sl@0
|
42 |
class TLeafDirData
|
sl@0
|
43 |
{
|
sl@0
|
44 |
public:
|
sl@0
|
45 |
TLeafDirData();
|
sl@0
|
46 |
TLeafDirData(TUint aClusterNum);
|
sl@0
|
47 |
TLeafDirData(TUint aClusterNum, const TEntryPos& aMRUPos);
|
sl@0
|
48 |
inline TBool operator==(const TLeafDirData &aDirPos) const;
|
sl@0
|
49 |
inline TBool operator!=(const TLeafDirData &aDirPos) const;
|
sl@0
|
50 |
public:
|
sl@0
|
51 |
TUint iClusterNum;
|
sl@0
|
52 |
TEntryPos iMRUPos;
|
sl@0
|
53 |
};
|
sl@0
|
54 |
|
sl@0
|
55 |
/*
|
sl@0
|
56 |
Class definition for the nodes of the leaf dir cache
|
sl@0
|
57 |
All cached direcotries are stored as nodes in a tree structure
|
sl@0
|
58 |
|
sl@0
|
59 |
*/
|
sl@0
|
60 |
class CLeafDirTreeNode : public CBase
|
sl@0
|
61 |
{
|
sl@0
|
62 |
public:
|
sl@0
|
63 |
// Types of the nodes
|
sl@0
|
64 |
enum TLeafDirTreeNodeType
|
sl@0
|
65 |
{
|
sl@0
|
66 |
ERoot, // Represents the root node, i.e. the root path
|
sl@0
|
67 |
ELeaf, // Represents a pure 'leaf' nodes, no child
|
sl@0
|
68 |
ELeafIntermediary, // Represents a 'leaf' node, but has at least one child
|
sl@0
|
69 |
EPureIntermediary, // Represents a pure 'intermediary' node, which only exists to share the common path of other nodes
|
sl@0
|
70 |
};
|
sl@0
|
71 |
|
sl@0
|
72 |
static CLeafDirTreeNode* NewL(CLeafDirTree* aOwnerTree, const TDesC& aPathName, const TLeafDirData& aDirPos, TLeafDirTreeNodeType aType);
|
sl@0
|
73 |
~CLeafDirTreeNode();
|
sl@0
|
74 |
inline CLeafDirTreeNode* Parent();
|
sl@0
|
75 |
inline void SetParent(CLeafDirTreeNode* aNode);
|
sl@0
|
76 |
inline RPointerArray<CLeafDirTreeNode>& Children();
|
sl@0
|
77 |
void MakeItChildL(CLeafDirTreeNode* aNode);
|
sl@0
|
78 |
TInt RemoveChild(CLeafDirTreeNode* aNode);
|
sl@0
|
79 |
inline const TLeafDirData& LeafDirData() const;
|
sl@0
|
80 |
inline TUint32 StartClusterNum() const;
|
sl@0
|
81 |
inline void SetLeafDirData(const TLeafDirData& aLeafDirData);
|
sl@0
|
82 |
inline const TDesC& Path() const;
|
sl@0
|
83 |
void SetPathL(const TDesC& aPathData);
|
sl@0
|
84 |
void SetType(const CLeafDirTreeNode::TLeafDirTreeNodeType aType);
|
sl@0
|
85 |
inline TBool IsRoot() const;
|
sl@0
|
86 |
inline TBool IsLeaf();
|
sl@0
|
87 |
inline TBool IsLeafIntermediary();
|
sl@0
|
88 |
inline TBool IsPureIntermediary();
|
sl@0
|
89 |
|
sl@0
|
90 |
private:
|
sl@0
|
91 |
void ConstructL(CLeafDirTree* aOwnerTree, const TDesC& aPathName);
|
sl@0
|
92 |
CLeafDirTreeNode(const TLeafDirData& aDirPos , TLeafDirTreeNodeType aType);
|
sl@0
|
93 |
CLeafDirTreeNode(const CLeafDirTreeNode& aLeafDirTreeNode);
|
sl@0
|
94 |
CLeafDirTreeNode* operator=(CLeafDirTreeNode& aLeafDirTreeNode);
|
sl@0
|
95 |
|
sl@0
|
96 |
private:
|
sl@0
|
97 |
CLeafDirTree* iOwnerTree; // A pointer to the owner of this node.
|
sl@0
|
98 |
CLeafDirTreeNode* iParent; // The parent of this node
|
sl@0
|
99 |
RPointerArray<CLeafDirTreeNode> iChildren; // The children of this node
|
sl@0
|
100 |
RBuf iPath; // The path of the direcotry this node represents
|
sl@0
|
101 |
TLeafDirData iLeafDirData; // The position of the direcotry this node represents
|
sl@0
|
102 |
TLeafDirTreeNodeType iNodeType; // The type of the node
|
sl@0
|
103 |
};
|
sl@0
|
104 |
|
sl@0
|
105 |
/*
|
sl@0
|
106 |
Class definition for the tree structure of the leaf dir cache
|
sl@0
|
107 |
All cached direcotries are stored as nodes in a tree structure
|
sl@0
|
108 |
|
sl@0
|
109 |
*/
|
sl@0
|
110 |
class CLeafDirTree : public CBase
|
sl@0
|
111 |
{
|
sl@0
|
112 |
public:
|
sl@0
|
113 |
static CLeafDirTree* NewL(TUint32 aSize);
|
sl@0
|
114 |
~CLeafDirTree();
|
sl@0
|
115 |
|
sl@0
|
116 |
public:
|
sl@0
|
117 |
TInt Search(const TDesC& aPath, CLeafDirTreeNode*& aNodeFound, TLeafDirData& aDirPos);
|
sl@0
|
118 |
TInt DoSearch(const TDesC& aPath, CLeafDirTreeNode* aNodeToStart, CLeafDirTreeNode*& aNodeFound, TLeafDirData& aDirPos);
|
sl@0
|
119 |
void InsertL(const TDesC& aPath, const TLeafDirData& aDirPos, CLeafDirTreeNode*& aNodeInserted);
|
sl@0
|
120 |
void DoInsertL(CLeafDirTreeNode* aNodeToStart, const TDesC& aPath, const TLeafDirData& aDirPos, CLeafDirTreeNode*& aNodeInserted);
|
sl@0
|
121 |
void RemoveDirL(const TLeafDirData& aDirPos);
|
sl@0
|
122 |
void UpdateMRUPos(const TLeafDirData& aLeafDirData);
|
sl@0
|
123 |
void RemoveFromCacheL(CLeafDirTreeNode* aNodeToDelete);
|
sl@0
|
124 |
CLeafDirTreeNode* FindLeftestLeafNode(CLeafDirTreeNode* aNodeToStart) const;
|
sl@0
|
125 |
void DeleteSubTreeL(CLeafDirTreeNode* aNodeToStart);
|
sl@0
|
126 |
void Reset();
|
sl@0
|
127 |
CLeafDirTreeNode* LruNode();
|
sl@0
|
128 |
void AddOntoLruL(CLeafDirTreeNode* aNodeToAdd);
|
sl@0
|
129 |
TInt RemoveFromLru(CLeafDirTreeNode* aNodeToRemove);
|
sl@0
|
130 |
TInt MakeMostRecentlyUsed(CLeafDirTreeNode* aNodeUsed);
|
sl@0
|
131 |
inline TInt LruCount() const;
|
sl@0
|
132 |
void CheckLimitL();
|
sl@0
|
133 |
|
sl@0
|
134 |
// For debugging & testing only
|
sl@0
|
135 |
#ifdef _DEBUG
|
sl@0
|
136 |
TInt ObjectCount() const {return iContainer.Count();};
|
sl@0
|
137 |
void AddToObjectContainerL(CLeafDirTreeNode* aNode);
|
sl@0
|
138 |
void RemoveFromObjectContainerL(CLeafDirTreeNode* aNode);
|
sl@0
|
139 |
void DumpTreeContentL() const;
|
sl@0
|
140 |
#endif //_DEBUG
|
sl@0
|
141 |
|
sl@0
|
142 |
private:
|
sl@0
|
143 |
void ConstructL();
|
sl@0
|
144 |
CLeafDirTree(TUint32 aSize);
|
sl@0
|
145 |
|
sl@0
|
146 |
private:
|
sl@0
|
147 |
CLeafDirTreeNode* iRoot; // The root node
|
sl@0
|
148 |
RPointerArray<CLeafDirTreeNode> iLruList; // The list containing all the LRU cached nodes
|
sl@0
|
149 |
TUint32 iSize; // The maximum number of items allowed to cache
|
sl@0
|
150 |
|
sl@0
|
151 |
// For debugging & testing only
|
sl@0
|
152 |
#ifdef _DEBUG
|
sl@0
|
153 |
RPointerArray<CLeafDirTreeNode> iContainer; // The container containing all nodes
|
sl@0
|
154 |
#endif //_DEBUG
|
sl@0
|
155 |
};
|
sl@0
|
156 |
|
sl@0
|
157 |
/*
|
sl@0
|
158 |
Class definition for leaf directory cache.
|
sl@0
|
159 |
Acting as an interface class for CFatMountCB to use.
|
sl@0
|
160 |
|
sl@0
|
161 |
*/
|
sl@0
|
162 |
class CLeafDirCache : public CBase
|
sl@0
|
163 |
{
|
sl@0
|
164 |
public:
|
sl@0
|
165 |
static CLeafDirCache* NewL(TUint32 aLimit);
|
sl@0
|
166 |
~CLeafDirCache();
|
sl@0
|
167 |
void Reset();
|
sl@0
|
168 |
TInt FindInCache(const TDesC& aLeafDirName, TLeafDirData& aDirPos) const;
|
sl@0
|
169 |
void AddToCacheL(const TDesC& aLeafDirName, const TLeafDirData& aDirPos);
|
sl@0
|
170 |
void RemoveDirL(const TLeafDirData& aDirPos);
|
sl@0
|
171 |
void UpdateMRUPos(const TLeafDirData& aLeafDirData);
|
sl@0
|
172 |
TInt CacheCount() const;
|
sl@0
|
173 |
|
sl@0
|
174 |
// For debugging & testing only
|
sl@0
|
175 |
#ifdef _DEBUG
|
sl@0
|
176 |
void DumpCacheContentL() const;
|
sl@0
|
177 |
TInt NodeCount() const;
|
sl@0
|
178 |
#endif //_DEBUG
|
sl@0
|
179 |
|
sl@0
|
180 |
private:
|
sl@0
|
181 |
CLeafDirCache(TUint32 aLimit);
|
sl@0
|
182 |
void ConstructL();
|
sl@0
|
183 |
|
sl@0
|
184 |
private:
|
sl@0
|
185 |
TUint32 iSize; // The cache size
|
sl@0
|
186 |
CLeafDirTree* iTree; // The cache content, represented as a tree structure
|
sl@0
|
187 |
};
|
sl@0
|
188 |
|
sl@0
|
189 |
//---------------------------------------------------------------------------------------------------------------------------------
|
sl@0
|
190 |
|
sl@0
|
191 |
#include"sl_leafdir_cache.inl"
|
sl@0
|
192 |
|
sl@0
|
193 |
#endif //SL_LEAFDIR_CACHE_H
|
sl@0
|
194 |
|
sl@0
|
195 |
|
sl@0
|
196 |
|
sl@0
|
197 |
|