29 using System.Collections.Generic;
30 using System.Reflection;
34 namespace OpenSim.Framework
40 public static readonly
string PATH_DELIMITER =
"/";
45 public Dictionary<UUID, InventoryItemBase> Items =
new Dictionary<UUID, InventoryItemBase>();
50 protected Dictionary<UUID, InventoryFolderImpl> m_childFolders =
new Dictionary<UUID, InventoryFolderImpl>();
55 Owner = folderbase.Owner;
57 Name = folderbase.Name;
59 Type = folderbase.Type;
60 Version = folderbase.Version;
78 if (!m_childFolders.ContainsKey(folderID))
81 subFold.Name = folderName;
82 subFold.ID = folderID;
83 subFold.Type = (short)type;
84 subFold.ParentID = this.ID;
85 subFold.Owner =
Owner;
86 m_childFolders.Add(subFold.ID, subFold);
101 lock (m_childFolders)
103 folder.ParentID = ID;
104 m_childFolders[folder.ID] = folder;
115 return m_childFolders.ContainsKey(folderID);
127 lock (m_childFolders)
129 m_childFolders.TryGetValue(folderID, out folder);
146 lock (m_childFolders)
148 if (m_childFolders.ContainsKey(folderID))
150 removedFolder = m_childFolders[folderID];
151 m_childFolders.Remove(folderID);
155 return removedFolder;
168 m_childFolders.Clear();
181 if (Items.ContainsKey(itemID))
183 return Items[itemID];
187 lock (m_childFolders)
214 lock (m_childFolders)
241 if (Items.ContainsKey(itemID))
243 Items.Remove(itemID);
248 lock (m_childFolders)
252 found = folder.DeleteItem(itemID);
274 lock (m_childFolders)
280 if (returnFolder != null)
295 lock (m_childFolders)
325 if (path ==
string.Empty)
330 if (path == PATH_DELIMITER)
333 string[] components = path.Split(
new string[] { PATH_DELIMITER }, 2, StringSplitOptions.None);
335 lock (m_childFolders)
339 if (folder.
Name == components[0])
340 if (components.Length > 1)
341 return folder.FindFolderByPath(components[1]);
367 string[] components = path.Split(
new string[] { PATH_DELIMITER }, 2, StringSplitOptions.None);
369 if (components.Length == 1)
375 if (item.
Name == components[0])
382 lock (m_childFolders)
386 if (folder.
Name == components[0])
387 return folder.FindItemByPath(components[1]);
401 List<InventoryItemBase> itemList =
new List<InventoryItemBase>();
425 List<InventoryFolderBase> folderList =
new List<InventoryFolderBase>();
427 lock (m_childFolders)
431 folderList.Add(folder);
440 List<InventoryFolderImpl> folderList =
new List<InventoryFolderImpl>();
442 lock (m_childFolders)
446 folderList.Add(folder);
457 public int TotalCount
461 int total = Items.Count;
465 total = total + folder.TotalCount;
List< InventoryFolderImpl > RequestListOfFolderImpls()
List< InventoryFolderBase > RequestListOfFolders()
Return a copy of the list of child folders in this folder. The folders themselves are the originals...
void Purge()
Delete all the folders and items in this folder.
bool ContainsChildFolder(UUID folderID)
Does this folder contain the given child folder?
InventoryFolderImpl FindFolder(UUID folderID)
Returns the folder requested if it is this folder or is a descendent of this folder. The search is depth first.
InventoryItemBase FindItemByPath(string path)
Find an item given a PATH_DELIMITOR delimited path starting from this folder.
InventoryFolderImpl(InventoryFolderBase folderbase)
InventoryFolderImpl CreateChildFolder(UUID folderID, string folderName, ushort type)
Create a new subfolder.
InventoryItemBase FindItem(UUID itemID)
Returns the item if it exists in this folder or in any of this folder's descendant folders ...
InventoryItemBase FindAsset(UUID assetID)
InventoryFolderImpl FindFolderForType(int type)
Look through all child subfolders for a folder marked as one for a particular asset type...
List< InventoryItemBase > RequestListOfItems()
Return a copy of the list of child items in this folder. The items themselves are the originals...
InventoryFolderImpl RemoveChildFolder(UUID folderID)
Removes the given child subfolder.
InventoryFolderImpl FindFolderByPath(string path)
Find a folder given a PATH_DELIMITER delimited path starting from this folder
Inventory Item - contains all the properties associated with an individual inventory piece...
virtual string Name
The name of the node (64 characters or less)
bool DeleteItem(UUID itemID)
Deletes an item if it exists in this folder or any children
InventoryFolderImpl GetChildFolder(UUID folderID)
Get a child folder
void AddChildFolder(InventoryFolderImpl folder)
Add a folder that already exists.