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\sfat32\inc\sl_leafdir_cache.h
23 //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
24 //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
26 //!! WARNING!! DO NOT edit this file !! '\sfat' component is obsolete and is not being used. '\sfat32'replaces it
28 //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
29 //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
32 #ifndef SL_LEAFDIR_CACHE_H
33 #define SL_LEAFDIR_CACHE_H
35 //---------------------------------------------------------------------------------------------------------------------------------
40 A data structure to define the location of a direcotry
46 TLeafDirData(TUint aClusterNum);
47 TLeafDirData(TUint aClusterNum, const TEntryPos& aMRUPos);
48 inline TBool operator==(const TLeafDirData &aDirPos) const;
49 inline TBool operator!=(const TLeafDirData &aDirPos) const;
56 Class definition for the nodes of the leaf dir cache
57 All cached direcotries are stored as nodes in a tree structure
60 class CLeafDirTreeNode : public CBase
64 enum TLeafDirTreeNodeType
66 ERoot, // Represents the root node, i.e. the root path
67 ELeaf, // Represents a pure 'leaf' nodes, no child
68 ELeafIntermediary, // Represents a 'leaf' node, but has at least one child
69 EPureIntermediary, // Represents a pure 'intermediary' node, which only exists to share the common path of other nodes
72 static CLeafDirTreeNode* NewL(CLeafDirTree* aOwnerTree, const TDesC& aPathName, const TLeafDirData& aDirPos, TLeafDirTreeNodeType aType);
74 inline CLeafDirTreeNode* Parent();
75 inline void SetParent(CLeafDirTreeNode* aNode);
76 inline RPointerArray<CLeafDirTreeNode>& Children();
77 void MakeItChildL(CLeafDirTreeNode* aNode);
78 TInt RemoveChild(CLeafDirTreeNode* aNode);
79 inline const TLeafDirData& LeafDirData() const;
80 inline TUint32 StartClusterNum() const;
81 inline void SetLeafDirData(const TLeafDirData& aLeafDirData);
82 inline const TDesC& Path() const;
83 void SetPathL(const TDesC& aPathData);
84 void SetType(const CLeafDirTreeNode::TLeafDirTreeNodeType aType);
85 inline TBool IsRoot() const;
86 inline TBool IsLeaf();
87 inline TBool IsLeafIntermediary();
88 inline TBool IsPureIntermediary();
91 void ConstructL(CLeafDirTree* aOwnerTree, const TDesC& aPathName);
92 CLeafDirTreeNode(const TLeafDirData& aDirPos , TLeafDirTreeNodeType aType);
93 CLeafDirTreeNode(const CLeafDirTreeNode& aLeafDirTreeNode);
94 CLeafDirTreeNode* operator=(CLeafDirTreeNode& aLeafDirTreeNode);
97 CLeafDirTree* iOwnerTree; // A pointer to the owner of this node.
98 CLeafDirTreeNode* iParent; // The parent of this node
99 RPointerArray<CLeafDirTreeNode> iChildren; // The children of this node
100 RBuf iPath; // The path of the direcotry this node represents
101 TLeafDirData iLeafDirData; // The position of the direcotry this node represents
102 TLeafDirTreeNodeType iNodeType; // The type of the node
106 Class definition for the tree structure of the leaf dir cache
107 All cached direcotries are stored as nodes in a tree structure
110 class CLeafDirTree : public CBase
113 static CLeafDirTree* NewL(TUint32 aSize);
117 TInt Search(const TDesC& aPath, CLeafDirTreeNode*& aNodeFound, TLeafDirData& aDirPos);
118 TInt DoSearch(const TDesC& aPath, CLeafDirTreeNode* aNodeToStart, CLeafDirTreeNode*& aNodeFound, TLeafDirData& aDirPos);
119 void InsertL(const TDesC& aPath, const TLeafDirData& aDirPos, CLeafDirTreeNode*& aNodeInserted);
120 void DoInsertL(CLeafDirTreeNode* aNodeToStart, const TDesC& aPath, const TLeafDirData& aDirPos, CLeafDirTreeNode*& aNodeInserted);
121 void RemoveDirL(const TLeafDirData& aDirPos);
122 void UpdateMRUPos(const TLeafDirData& aLeafDirData);
123 void RemoveFromCacheL(CLeafDirTreeNode* aNodeToDelete);
124 CLeafDirTreeNode* FindLeftestLeafNode(CLeafDirTreeNode* aNodeToStart) const;
125 void DeleteSubTreeL(CLeafDirTreeNode* aNodeToStart);
127 CLeafDirTreeNode* LruNode();
128 void AddOntoLruL(CLeafDirTreeNode* aNodeToAdd);
129 TInt RemoveFromLru(CLeafDirTreeNode* aNodeToRemove);
130 TInt MakeMostRecentlyUsed(CLeafDirTreeNode* aNodeUsed);
131 inline TInt LruCount() const;
134 // For debugging & testing only
136 TInt ObjectCount() const {return iContainer.Count();};
137 void AddToObjectContainerL(CLeafDirTreeNode* aNode);
138 void RemoveFromObjectContainerL(CLeafDirTreeNode* aNode);
139 void DumpTreeContentL() const;
144 CLeafDirTree(TUint32 aSize);
147 CLeafDirTreeNode* iRoot; // The root node
148 RPointerArray<CLeafDirTreeNode> iLruList; // The list containing all the LRU cached nodes
149 TUint32 iSize; // The maximum number of items allowed to cache
151 // For debugging & testing only
153 RPointerArray<CLeafDirTreeNode> iContainer; // The container containing all nodes
158 Class definition for leaf directory cache.
159 Acting as an interface class for CFatMountCB to use.
162 class CLeafDirCache : public CBase
165 static CLeafDirCache* NewL(TUint32 aLimit);
168 TInt FindInCache(const TDesC& aLeafDirName, TLeafDirData& aDirPos) const;
169 void AddToCacheL(const TDesC& aLeafDirName, const TLeafDirData& aDirPos);
170 void RemoveDirL(const TLeafDirData& aDirPos);
171 void UpdateMRUPos(const TLeafDirData& aLeafDirData);
172 TInt CacheCount() const;
174 // For debugging & testing only
176 void DumpCacheContentL() const;
177 TInt NodeCount() const;
181 CLeafDirCache(TUint32 aLimit);
185 TUint32 iSize; // The cache size
186 CLeafDirTree* iTree; // The cache content, represented as a tree structure
189 //---------------------------------------------------------------------------------------------------------------------------------
191 #include"sl_leafdir_cache.inl"
193 #endif //SL_LEAFDIR_CACHE_H