diff options
author | Jeff Ames | 2009-07-01 23:37:09 +0000 |
---|---|---|
committer | Jeff Ames | 2009-07-01 23:37:09 +0000 |
commit | 1d01d6d919ec55e59d5c9b20a978aa6b802bd45d (patch) | |
tree | 8a76a2c91c3c6ea1b34d5564cb6e8bc5efed0883 /OpenSim/Region/OptionalModules/Scripting/Minimodule/SOPObjectInventory.cs | |
parent | Add copyright headers. (diff) | |
download | opensim-SC-1d01d6d919ec55e59d5c9b20a978aa6b802bd45d.zip opensim-SC-1d01d6d919ec55e59d5c9b20a978aa6b802bd45d.tar.gz opensim-SC-1d01d6d919ec55e59d5c9b20a978aa6b802bd45d.tar.bz2 opensim-SC-1d01d6d919ec55e59d5c9b20a978aa6b802bd45d.tar.xz |
Formatting cleanup.
Diffstat (limited to '')
-rw-r--r-- | OpenSim/Region/OptionalModules/Scripting/Minimodule/SOPObjectInventory.cs | 336 |
1 files changed, 168 insertions, 168 deletions
diff --git a/OpenSim/Region/OptionalModules/Scripting/Minimodule/SOPObjectInventory.cs b/OpenSim/Region/OptionalModules/Scripting/Minimodule/SOPObjectInventory.cs index cae49a3..d20f4a4 100644 --- a/OpenSim/Region/OptionalModules/Scripting/Minimodule/SOPObjectInventory.cs +++ b/OpenSim/Region/OptionalModules/Scripting/Minimodule/SOPObjectInventory.cs | |||
@@ -35,181 +35,181 @@ using OpenMetaverse; | |||
35 | 35 | ||
36 | namespace OpenSim.Region.OptionalModules.Scripting.Minimodule.Object | 36 | namespace OpenSim.Region.OptionalModules.Scripting.Minimodule.Object |
37 | { | 37 | { |
38 | public class SOPObjectInventory : IObjectInventory | 38 | public class SOPObjectInventory : IObjectInventory |
39 | { | 39 | { |
40 | TaskInventoryDictionary m_privateInventory; /// OpenSim's task inventory | 40 | TaskInventoryDictionary m_privateInventory; /// OpenSim's task inventory |
41 | Dictionary<UUID, IInventoryItem> m_publicInventory; /// MRM's inventory | 41 | Dictionary<UUID, IInventoryItem> m_publicInventory; /// MRM's inventory |
42 | Scene m_rootScene; | 42 | Scene m_rootScene; |
43 | 43 | ||
44 | public SOPObjectInventory(Scene rootScene, TaskInventoryDictionary taskInventory) | 44 | public SOPObjectInventory(Scene rootScene, TaskInventoryDictionary taskInventory) |
45 | { | 45 | { |
46 | m_rootScene = rootScene; | 46 | m_rootScene = rootScene; |
47 | m_privateInventory = taskInventory; | 47 | m_privateInventory = taskInventory; |
48 | m_publicInventory = new Dictionary<UUID, IInventoryItem>(); | 48 | m_publicInventory = new Dictionary<UUID, IInventoryItem>(); |
49 | } | 49 | } |
50 | 50 | ||
51 | /// <summary> | 51 | /// <summary> |
52 | /// Fully populate the public dictionary with the contents of the private dictionary | 52 | /// Fully populate the public dictionary with the contents of the private dictionary |
53 | /// </summary> | 53 | /// </summary> |
54 | /// <description> | 54 | /// <description> |
55 | /// This will only convert those items which hasn't already been converted. ensuring that | 55 | /// This will only convert those items which hasn't already been converted. ensuring that |
56 | /// no items are converted twice, and that any references already in use are maintained. | 56 | /// no items are converted twice, and that any references already in use are maintained. |
57 | /// </description> | 57 | /// </description> |
58 | private void SynchronizeDictionaries() | 58 | private void SynchronizeDictionaries() |
59 | { | 59 | { |
60 | foreach(TaskInventoryItem privateItem in m_privateInventory.Values) | 60 | foreach (TaskInventoryItem privateItem in m_privateInventory.Values) |
61 | if(!m_publicInventory.ContainsKey(privateItem.ItemID)) | 61 | if (!m_publicInventory.ContainsKey(privateItem.ItemID)) |
62 | m_publicInventory.Add(privateItem.ItemID, new InventoryItem(m_rootScene, privateItem)); | 62 | m_publicInventory.Add(privateItem.ItemID, new InventoryItem(m_rootScene, privateItem)); |
63 | } | 63 | } |
64 | 64 | ||
65 | #region IDictionary<UUID, IInventoryItem> implementation | 65 | #region IDictionary<UUID, IInventoryItem> implementation |
66 | public void Add (UUID key, IInventoryItem value) | 66 | public void Add (UUID key, IInventoryItem value) |
67 | { | 67 | { |
68 | m_publicInventory.Add(key, value); | 68 | m_publicInventory.Add(key, value); |
69 | m_privateInventory.Add(key, InventoryItem.FromInterface(value).ToTaskInventoryItem()); | 69 | m_privateInventory.Add(key, InventoryItem.FromInterface(value).ToTaskInventoryItem()); |
70 | } | 70 | } |
71 | 71 | ||
72 | public bool ContainsKey (UUID key) | 72 | public bool ContainsKey (UUID key) |
73 | { | 73 | { |
74 | return m_privateInventory.ContainsKey(key); | 74 | return m_privateInventory.ContainsKey(key); |
75 | } | 75 | } |
76 | 76 | ||
77 | public bool Remove (UUID key) | 77 | public bool Remove (UUID key) |
78 | { | 78 | { |
79 | m_publicInventory.Remove(key); | 79 | m_publicInventory.Remove(key); |
80 | return m_privateInventory.Remove(key); | 80 | return m_privateInventory.Remove(key); |
81 | } | 81 | } |
82 | 82 | ||
83 | public bool TryGetValue (UUID key, out IInventoryItem value) | 83 | public bool TryGetValue (UUID key, out IInventoryItem value) |
84 | { | 84 | { |
85 | value = null; | 85 | value = null; |
86 | 86 | ||
87 | bool result = false; | 87 | bool result = false; |
88 | if(!m_publicInventory.TryGetValue(key, out value)) | 88 | if (!m_publicInventory.TryGetValue(key, out value)) |
89 | { | 89 | { |
90 | // wasn't found in the public inventory | 90 | // wasn't found in the public inventory |
91 | TaskInventoryItem privateItem; | 91 | TaskInventoryItem privateItem; |
92 | 92 | ||
93 | result = m_privateInventory.TryGetValue(key, out privateItem); | 93 | result = m_privateInventory.TryGetValue(key, out privateItem); |
94 | if(result) | 94 | if (result) |
95 | { | 95 | { |
96 | value = new InventoryItem(m_rootScene, privateItem); | 96 | value = new InventoryItem(m_rootScene, privateItem); |
97 | m_publicInventory.Add(key, value); // add item, so we don't convert again | 97 | m_publicInventory.Add(key, value); // add item, so we don't convert again |
98 | } | 98 | } |
99 | } else | 99 | } else |
100 | return true; | 100 | return true; |
101 | 101 | ||
102 | return result; | 102 | return result; |
103 | } | 103 | } |
104 | 104 | ||
105 | public ICollection<UUID> Keys { | 105 | public ICollection<UUID> Keys { |
106 | get { | 106 | get { |
107 | return m_privateInventory.Keys; | 107 | return m_privateInventory.Keys; |
108 | } | 108 | } |
109 | } | 109 | } |
110 | 110 | ||
111 | public ICollection<IInventoryItem> Values { | 111 | public ICollection<IInventoryItem> Values { |
112 | get { | 112 | get { |
113 | SynchronizeDictionaries(); | 113 | SynchronizeDictionaries(); |
114 | return m_publicInventory.Values; | 114 | return m_publicInventory.Values; |
115 | } | 115 | } |
116 | } | 116 | } |
117 | #endregion | 117 | #endregion |
118 | 118 | ||
119 | #region IEnumerable<KeyValuePair<UUID, IInventoryItem>> implementation | 119 | #region IEnumerable<KeyValuePair<UUID, IInventoryItem>> implementation |
120 | public IEnumerator<KeyValuePair<UUID, IInventoryItem>> GetEnumerator () | 120 | public IEnumerator<KeyValuePair<UUID, IInventoryItem>> GetEnumerator () |
121 | { | 121 | { |
122 | SynchronizeDictionaries(); | 122 | SynchronizeDictionaries(); |
123 | return m_publicInventory.GetEnumerator(); | 123 | return m_publicInventory.GetEnumerator(); |
124 | } | 124 | } |
125 | 125 | ||
126 | #endregion | 126 | #endregion |
127 | 127 | ||
128 | #region IEnumerable implementation | 128 | #region IEnumerable implementation |
129 | IEnumerator IEnumerable.GetEnumerator () | 129 | IEnumerator IEnumerable.GetEnumerator () |
130 | { | 130 | { |
131 | SynchronizeDictionaries(); | 131 | SynchronizeDictionaries(); |
132 | return m_publicInventory.GetEnumerator(); | 132 | return m_publicInventory.GetEnumerator(); |
133 | } | 133 | } |
134 | 134 | ||
135 | #endregion | 135 | #endregion |
136 | 136 | ||
137 | #region ICollection<KeyValuePair<UUID, IInventoryItem>> implementation | 137 | #region ICollection<KeyValuePair<UUID, IInventoryItem>> implementation |
138 | public void Add (KeyValuePair<UUID, IInventoryItem> item) | 138 | public void Add (KeyValuePair<UUID, IInventoryItem> item) |
139 | { | 139 | { |
140 | Add(item.Key, item.Value); | 140 | Add(item.Key, item.Value); |
141 | } | 141 | } |
142 | 142 | ||
143 | public void Clear () | 143 | public void Clear () |
144 | { | 144 | { |
145 | m_publicInventory.Clear(); | 145 | m_publicInventory.Clear(); |
146 | m_privateInventory.Clear(); | 146 | m_privateInventory.Clear(); |
147 | } | 147 | } |
148 | 148 | ||
149 | public bool Contains (KeyValuePair<UUID, IInventoryItem> item) | 149 | public bool Contains (KeyValuePair<UUID, IInventoryItem> item) |
150 | { | 150 | { |
151 | return m_privateInventory.ContainsKey(item.Key); | 151 | return m_privateInventory.ContainsKey(item.Key); |
152 | } | 152 | } |
153 | 153 | ||
154 | public void CopyTo (KeyValuePair<UUID, IInventoryItem>[] array, int arrayIndex) | 154 | public void CopyTo (KeyValuePair<UUID, IInventoryItem>[] array, int arrayIndex) |
155 | { | 155 | { |
156 | throw new NotImplementedException(); | 156 | throw new NotImplementedException(); |
157 | } | 157 | } |
158 | 158 | ||
159 | public bool Remove (KeyValuePair<UUID, IInventoryItem> item) | 159 | public bool Remove (KeyValuePair<UUID, IInventoryItem> item) |
160 | { | 160 | { |
161 | return Remove(item.Key); | 161 | return Remove(item.Key); |
162 | } | 162 | } |
163 | 163 | ||
164 | public int Count { | 164 | public int Count { |
165 | get { | 165 | get { |
166 | return m_privateInventory.Count; | 166 | return m_privateInventory.Count; |
167 | } | 167 | } |
168 | } | 168 | } |
169 | 169 | ||
170 | public bool IsReadOnly { | 170 | public bool IsReadOnly { |
171 | get { | 171 | get { |
172 | return false; | 172 | return false; |
173 | } | 173 | } |
174 | } | 174 | } |
175 | #endregion | 175 | #endregion |
176 | 176 | ||
177 | #region Explicit implementations | 177 | #region Explicit implementations |
178 | IInventoryItem System.Collections.Generic.IDictionary<UUID, IInventoryItem>.this[UUID key] | 178 | IInventoryItem System.Collections.Generic.IDictionary<UUID, IInventoryItem>.this[UUID key] |
179 | { | 179 | { |
180 | get { | 180 | get { |
181 | IInventoryItem result; | 181 | IInventoryItem result; |
182 | if(TryGetValue(key, out result)) | 182 | if (TryGetValue(key, out result)) |
183 | return result; | 183 | return result; |
184 | else | 184 | else |
185 | throw new KeyNotFoundException("[MRM] The requrested item ID could not be found"); | 185 | throw new KeyNotFoundException("[MRM] The requrested item ID could not be found"); |
186 | } | 186 | } |
187 | set { | 187 | set { |
188 | m_publicInventory[key] = value; | 188 | m_publicInventory[key] = value; |
189 | m_privateInventory[key] = InventoryItem.FromInterface(value).ToTaskInventoryItem(); | 189 | m_privateInventory[key] = InventoryItem.FromInterface(value).ToTaskInventoryItem(); |
190 | } | 190 | } |
191 | } | 191 | } |
192 | 192 | ||
193 | void System.Collections.Generic.ICollection<System.Collections.Generic.KeyValuePair<UUID, IInventoryItem>>.CopyTo(System.Collections.Generic.KeyValuePair<UUID,IInventoryItem>[] array, int offset) | 193 | void System.Collections.Generic.ICollection<System.Collections.Generic.KeyValuePair<UUID, IInventoryItem>>.CopyTo(System.Collections.Generic.KeyValuePair<UUID,IInventoryItem>[] array, int offset) |
194 | { | 194 | { |
195 | throw new NotImplementedException(); | 195 | throw new NotImplementedException(); |
196 | } | 196 | } |
197 | #endregion | 197 | #endregion |
198 | 198 | ||
199 | public IInventoryItem this[string name] | 199 | public IInventoryItem this[string name] |
200 | { | 200 | { |
201 | get { | 201 | get { |
202 | foreach(TaskInventoryItem i in m_privateInventory.Values) | 202 | foreach (TaskInventoryItem i in m_privateInventory.Values) |
203 | if(i.Name == name) | 203 | if (i.Name == name) |
204 | { | 204 | { |
205 | if(!m_publicInventory.ContainsKey(i.ItemID)) | 205 | if (!m_publicInventory.ContainsKey(i.ItemID)) |
206 | m_publicInventory.Add(i.ItemID, new InventoryItem(m_rootScene, i)); | 206 | m_publicInventory.Add(i.ItemID, new InventoryItem(m_rootScene, i)); |
207 | 207 | ||
208 | return m_publicInventory[i.ItemID]; | 208 | return m_publicInventory[i.ItemID]; |
209 | } | 209 | } |
210 | throw new KeyNotFoundException(); | 210 | throw new KeyNotFoundException(); |
211 | } | 211 | } |
212 | } | 212 | } |
213 | 213 | ||
214 | } | 214 | } |
215 | } | 215 | } |