From 80e267dcfec335c5402922c4eb5587df9603f94d Mon Sep 17 00:00:00 2001
From: Justin Clarke Casey
Date: Thu, 11 Dec 2008 20:58:11 +0000
Subject: * refactor: Stop exposing InventoryFolderImpl.SubFolders publicly
---
.../Communications/Cache/InventoryFolderImpl.cs | 93 ++++++++++++++--------
1 file changed, 61 insertions(+), 32 deletions(-)
(limited to 'OpenSim/Framework/Communications/Cache/InventoryFolderImpl.cs')
diff --git a/OpenSim/Framework/Communications/Cache/InventoryFolderImpl.cs b/OpenSim/Framework/Communications/Cache/InventoryFolderImpl.cs
index 933d40a..4c629f4 100644
--- a/OpenSim/Framework/Communications/Cache/InventoryFolderImpl.cs
+++ b/OpenSim/Framework/Communications/Cache/InventoryFolderImpl.cs
@@ -48,7 +48,7 @@ namespace OpenSim.Framework.Communications.Cache
///
/// Child folders that are contained in this folder
///
- public Dictionary SubFolders = new Dictionary();
+ protected Dictionary m_childFolders = new Dictionary();
// Constructors
public InventoryFolderImpl(InventoryFolderBase folderbase)
@@ -74,9 +74,9 @@ namespace OpenSim.Framework.Communications.Cache
/// The newly created subfolder. Returns null if the folder already exists
public InventoryFolderImpl CreateChildFolder(UUID folderID, string folderName, ushort type)
{
- lock (SubFolders)
+ lock (m_childFolders)
{
- if (!SubFolders.ContainsKey(folderID))
+ if (!m_childFolders.ContainsKey(folderID))
{
InventoryFolderImpl subFold = new InventoryFolderImpl();
subFold.Name = folderName;
@@ -84,7 +84,7 @@ namespace OpenSim.Framework.Communications.Cache
subFold.Type = (short) type;
subFold.ParentID = this.ID;
subFold.Owner = Owner;
- SubFolders.Add(subFold.ID, subFold);
+ m_childFolders.Add(subFold.ID, subFold);
return subFold;
}
@@ -99,14 +99,24 @@ namespace OpenSim.Framework.Communications.Cache
///
public void AddChildFolder(InventoryFolderImpl folder)
{
- lock (SubFolders)
+ lock (m_childFolders)
{
folder.ParentID = ID;
- SubFolders[folder.ID] = folder;
+ m_childFolders[folder.ID] = folder;
}
}
///
+ /// Does this folder contain the given child folder?
+ ///
+ ///
+ ///
+ public bool ContainsChildFolder(UUID folderID)
+ {
+ return m_childFolders.ContainsKey(folderID);
+ }
+
+ ///
/// Get a child folder
///
///
@@ -115,9 +125,9 @@ namespace OpenSim.Framework.Communications.Cache
{
InventoryFolderImpl folder = null;
- lock (SubFolders)
+ lock (m_childFolders)
{
- SubFolders.TryGetValue(folderID, out folder);
+ m_childFolders.TryGetValue(folderID, out folder);
}
return folder;
@@ -134,12 +144,12 @@ namespace OpenSim.Framework.Communications.Cache
{
InventoryFolderImpl removedFolder = null;
- lock (SubFolders)
+ lock (m_childFolders)
{
- if (SubFolders.ContainsKey(folderID))
+ if (m_childFolders.ContainsKey(folderID))
{
- removedFolder = SubFolders[folderID];
- SubFolders.Remove(folderID);
+ removedFolder = m_childFolders[folderID];
+ m_childFolders.Remove(folderID);
}
}
@@ -151,12 +161,12 @@ namespace OpenSim.Framework.Communications.Cache
///
public void Purge()
{
- foreach (InventoryFolderImpl folder in SubFolders.Values)
+ foreach (InventoryFolderImpl folder in m_childFolders.Values)
{
folder.Purge();
}
- SubFolders.Clear();
+ m_childFolders.Clear();
Items.Clear();
}
@@ -175,9 +185,9 @@ namespace OpenSim.Framework.Communications.Cache
}
}
- lock (SubFolders)
+ lock (m_childFolders)
{
- foreach (InventoryFolderImpl folder in SubFolders.Values)
+ foreach (InventoryFolderImpl folder in m_childFolders.Values)
{
InventoryItemBase item = folder.FindItem(itemID);
@@ -202,9 +212,9 @@ namespace OpenSim.Framework.Communications.Cache
}
}
- lock (SubFolders)
+ lock (m_childFolders)
{
- foreach (InventoryFolderImpl folder in SubFolders.Values)
+ foreach (InventoryFolderImpl folder in m_childFolders.Values)
{
InventoryItemBase item = folder.FindAsset(assetID);
@@ -236,9 +246,9 @@ namespace OpenSim.Framework.Communications.Cache
}
}
- lock (SubFolders)
+ lock (m_childFolders)
{
- foreach (InventoryFolderImpl folder in SubFolders.Values)
+ foreach (InventoryFolderImpl folder in m_childFolders.Values)
{
found = folder.DeleteItem(itemID);
@@ -262,9 +272,9 @@ namespace OpenSim.Framework.Communications.Cache
if (folderID == ID)
return this;
- lock (SubFolders)
+ lock (m_childFolders)
{
- foreach (InventoryFolderImpl folder in SubFolders.Values)
+ foreach (InventoryFolderImpl folder in m_childFolders.Values)
{
InventoryFolderImpl returnFolder = folder.FindFolder(folderID);
@@ -274,7 +284,26 @@ namespace OpenSim.Framework.Communications.Cache
}
return null;
- }
+ }
+
+ ///
+ /// Look through all child subfolders for a folder marked as one for a particular asset type, and return it.
+ ///
+ ///
+ /// Returns null if no such folder is found
+ public InventoryFolderImpl FindFolderForType(int type)
+ {
+ lock (m_childFolders)
+ {
+ foreach (InventoryFolderImpl f in m_childFolders.Values)
+ {
+ if (f.Type == type)
+ return f;
+ }
+ }
+
+ return null;
+ }
///
/// Find a folder given a PATH_DELIMITOR delimited path starting from this folder
@@ -297,9 +326,9 @@ namespace OpenSim.Framework.Communications.Cache
string[] components = path.Split(new string[] { PATH_DELIMITER }, 2, StringSplitOptions.None);
- lock (SubFolders)
+ lock (m_childFolders)
{
- foreach (InventoryFolderImpl folder in SubFolders.Values)
+ foreach (InventoryFolderImpl folder in m_childFolders.Values)
{
if (folder.Name == components[0])
if (components.Length > 1)
@@ -344,9 +373,9 @@ namespace OpenSim.Framework.Communications.Cache
}
else
{
- lock (SubFolders)
+ lock (m_childFolders)
{
- foreach (InventoryFolderImpl folder in SubFolders.Values)
+ foreach (InventoryFolderImpl folder in m_childFolders.Values)
{
if (folder.Name == components[0])
return folder.FindItemByPath(components[1]);
@@ -385,9 +414,9 @@ namespace OpenSim.Framework.Communications.Cache
{
List folderList = new List();
- lock (SubFolders)
+ lock (m_childFolders)
{
- foreach (InventoryFolderBase folder in SubFolders.Values)
+ foreach (InventoryFolderBase folder in m_childFolders.Values)
{
folderList.Add(folder);
}
@@ -400,9 +429,9 @@ namespace OpenSim.Framework.Communications.Cache
{
List folderList = new List();
- lock (SubFolders)
+ lock (m_childFolders)
{
- foreach (InventoryFolderImpl folder in SubFolders.Values)
+ foreach (InventoryFolderImpl folder in m_childFolders.Values)
{
folderList.Add(folder);
}
@@ -421,7 +450,7 @@ namespace OpenSim.Framework.Communications.Cache
{
int total = Items.Count;
- foreach (InventoryFolderImpl folder in SubFolders.Values)
+ foreach (InventoryFolderImpl folder in m_childFolders.Values)
{
total = total + folder.TotalCount;
}
--
cgit v1.1