aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim
diff options
context:
space:
mode:
authorJustin Clark-Casey (justincc)2010-08-16 22:21:46 +0100
committerJustin Clark-Casey (justincc)2013-01-25 04:03:11 +0000
commita6d9c263650cc23d60f941718f87a64aa2f360b2 (patch)
tree29bdd5df7bae66360e19a38c304e7197b6a55342 /OpenSim
parentImplement dynamic attribute persistence on mysql and mssql (diff)
downloadopensim-SC_OLD-a6d9c263650cc23d60f941718f87a64aa2f360b2.zip
opensim-SC_OLD-a6d9c263650cc23d60f941718f87a64aa2f360b2.tar.gz
opensim-SC_OLD-a6d9c263650cc23d60f941718f87a64aa2f360b2.tar.bz2
opensim-SC_OLD-a6d9c263650cc23d60f941718f87a64aa2f360b2.tar.xz
Encapsulate an OSDMap in DAMap (was DynAttrsOSDMap) rather than inheriting from it
This is the easier way to give us control over locking, rather than asking that OSDMap IDictionary methods be virtual
Diffstat (limited to 'OpenSim')
-rw-r--r--OpenSim/Data/MSSQL/MSSQLSimulationData.cs8
-rw-r--r--OpenSim/Data/MySQL/MySQLSimulationData.cs8
-rw-r--r--OpenSim/Data/SQLite/SQLiteSimulationData.cs8
-rw-r--r--OpenSim/Framework/DAMap.cs173
-rw-r--r--OpenSim/Framework/DynAttrsOSDMap.cs79
-rw-r--r--OpenSim/Framework/PrimitiveBaseShape.cs6
-rw-r--r--OpenSim/Region/CoreModules/Framework/DynamicAttributes/DAExampleModule.cs2
-rw-r--r--OpenSim/Region/Framework/Scenes/SceneObjectPart.cs4
8 files changed, 191 insertions, 97 deletions
diff --git a/OpenSim/Data/MSSQL/MSSQLSimulationData.cs b/OpenSim/Data/MSSQL/MSSQLSimulationData.cs
index e949738..e0e260d 100644
--- a/OpenSim/Data/MSSQL/MSSQLSimulationData.cs
+++ b/OpenSim/Data/MSSQL/MSSQLSimulationData.cs
@@ -1693,9 +1693,9 @@ VALUES
1693 prim.MediaUrl = (string)primRow["MediaURL"]; 1693 prim.MediaUrl = (string)primRow["MediaURL"];
1694 1694
1695 if (!(primRow["DynAttrs"] is System.DBNull)) 1695 if (!(primRow["DynAttrs"] is System.DBNull))
1696 prim.DynAttrs = DynAttrsOSDMap.FromXml((string)primRow["DynAttrs"]); 1696 prim.DynAttrs = DAMap.FromXml((string)primRow["DynAttrs"]);
1697 else 1697 else
1698 prim.DynAttrs = new DynAttrsOSDMap(); 1698 prim.DynAttrs = new DAMap();
1699 1699
1700 return prim; 1700 return prim;
1701 } 1701 }
@@ -1755,9 +1755,9 @@ VALUES
1755 } 1755 }
1756 1756
1757 if (!(shapeRow["DynAttrs"] is System.DBNull)) 1757 if (!(shapeRow["DynAttrs"] is System.DBNull))
1758 baseShape.DynAttrs = DynAttrsOSDMap.FromXml((string)shapeRow["DynAttrs"]); 1758 baseShape.DynAttrs = DAMap.FromXml((string)shapeRow["DynAttrs"]);
1759 else 1759 else
1760 baseShape.DynAttrs = new DynAttrsOSDMap(); 1760 baseShape.DynAttrs = new DAMap();
1761 1761
1762 return baseShape; 1762 return baseShape;
1763 } 1763 }
diff --git a/OpenSim/Data/MySQL/MySQLSimulationData.cs b/OpenSim/Data/MySQL/MySQLSimulationData.cs
index b7f39fb..e558702 100644
--- a/OpenSim/Data/MySQL/MySQLSimulationData.cs
+++ b/OpenSim/Data/MySQL/MySQLSimulationData.cs
@@ -1293,9 +1293,9 @@ namespace OpenSim.Data.MySQL
1293 prim.MediaUrl = (string)row["MediaURL"]; 1293 prim.MediaUrl = (string)row["MediaURL"];
1294 1294
1295 if (!(row["DynAttrs"] is System.DBNull)) 1295 if (!(row["DynAttrs"] is System.DBNull))
1296 prim.DynAttrs = DynAttrsOSDMap.FromXml((string)row["DynAttrs"]); 1296 prim.DynAttrs = DAMap.FromXml((string)row["DynAttrs"]);
1297 else 1297 else
1298 prim.DynAttrs = new DynAttrsOSDMap(); 1298 prim.DynAttrs = new DAMap();
1299 1299
1300 return prim; 1300 return prim;
1301 } 1301 }
@@ -1837,9 +1837,9 @@ namespace OpenSim.Data.MySQL
1837 s.Media = PrimitiveBaseShape.MediaList.FromXml((string)row["Media"]); 1837 s.Media = PrimitiveBaseShape.MediaList.FromXml((string)row["Media"]);
1838 1838
1839 if (!(row["DynAttrs"] is System.DBNull)) 1839 if (!(row["DynAttrs"] is System.DBNull))
1840 s.DynAttrs = DynAttrsOSDMap.FromXml((string)row["DynAttrs"]); 1840 s.DynAttrs = DAMap.FromXml((string)row["DynAttrs"]);
1841 else 1841 else
1842 s.DynAttrs = new DynAttrsOSDMap(); 1842 s.DynAttrs = new DAMap();
1843 1843
1844 return s; 1844 return s;
1845 } 1845 }
diff --git a/OpenSim/Data/SQLite/SQLiteSimulationData.cs b/OpenSim/Data/SQLite/SQLiteSimulationData.cs
index b97653b..6875ed6 100644
--- a/OpenSim/Data/SQLite/SQLiteSimulationData.cs
+++ b/OpenSim/Data/SQLite/SQLiteSimulationData.cs
@@ -1718,11 +1718,11 @@ namespace OpenSim.Data.SQLite
1718 if (!(row["DynAttrs"] is System.DBNull)) 1718 if (!(row["DynAttrs"] is System.DBNull))
1719 { 1719 {
1720 //m_log.DebugFormat("[SQLITE]: DynAttrs type [{0}]", row["DynAttrs"].GetType()); 1720 //m_log.DebugFormat("[SQLITE]: DynAttrs type [{0}]", row["DynAttrs"].GetType());
1721 prim.DynAttrs = DynAttrsOSDMap.FromXml((string)row["DynAttrs"]); 1721 prim.DynAttrs = DAMap.FromXml((string)row["DynAttrs"]);
1722 } 1722 }
1723 else 1723 else
1724 { 1724 {
1725 prim.DynAttrs = new DynAttrsOSDMap(); 1725 prim.DynAttrs = new DAMap();
1726 } 1726 }
1727 1727
1728 return prim; 1728 return prim;
@@ -2408,9 +2408,9 @@ namespace OpenSim.Data.SQLite
2408 s.Media = PrimitiveBaseShape.MediaList.FromXml((string)row["Media"]); 2408 s.Media = PrimitiveBaseShape.MediaList.FromXml((string)row["Media"]);
2409 2409
2410 if (!(row["DynAttrs"] is System.DBNull)) 2410 if (!(row["DynAttrs"] is System.DBNull))
2411 s.DynAttrs = DynAttrsOSDMap.FromXml((string)row["DynAttrs"]); 2411 s.DynAttrs = DAMap.FromXml((string)row["DynAttrs"]);
2412 else 2412 else
2413 s.DynAttrs = new DynAttrsOSDMap(); 2413 s.DynAttrs = new DAMap();
2414 2414
2415 return s; 2415 return s;
2416 } 2416 }
diff --git a/OpenSim/Framework/DAMap.cs b/OpenSim/Framework/DAMap.cs
new file mode 100644
index 0000000..a6fdf61
--- /dev/null
+++ b/OpenSim/Framework/DAMap.cs
@@ -0,0 +1,173 @@
1/*
2 * Copyright (c) Contributors, http://opensimulator.org/
3 * See CONTRIBUTORS.TXT for a full list of copyright holders.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 * * Neither the name of the OpenSimulator Project nor the
13 * names of its contributors may be used to endorse or promote products
14 * derived from this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27
28using System;
29using System.Collections;
30using System.Collections.Generic;
31using System.IO;
32using System.Text;
33using System.Xml;
34using System.Xml.Schema;
35using System.Xml.Serialization;
36using OpenMetaverse;
37using OpenMetaverse.StructuredData;
38
39namespace OpenSim.Framework
40{
41 /// <summary>
42 /// This is the map for storing and retrieving dynamic attributes.
43 /// </summary>
44 public class DAMap : IDictionary<string, OSD>, IXmlSerializable
45 {
46 protected OSDMap m_map;
47
48 public DAMap() { m_map = new OSDMap(); }
49
50 public XmlSchema GetSchema() { return null; }
51
52 public static DAMap FromXml(string rawXml)
53 {
54 DAMap map = new DAMap();
55 map.ReadXml(rawXml);
56 return map;
57 }
58
59 public void ReadXml(string rawXml)
60 {
61 //System.Console.WriteLine("Trying to deserialize [{0}]", rawXml);
62
63 m_map = (OSDMap)OSDParser.DeserializeLLSDXml(rawXml);
64 }
65
66 public void ReadXml(XmlReader reader)
67 {
68 ReadXml(reader.ReadInnerXml());
69 }
70
71 public string ToXml()
72 {
73 lock (m_map)
74 return OSDParser.SerializeLLSDXmlString(m_map);
75 }
76
77 public void WriteXml(XmlWriter writer)
78 {
79 writer.WriteRaw(ToXml());
80 }
81
82 public int Count { get { lock (m_map) { return m_map.Count; } } }
83 public bool IsReadOnly { get { return false; } }
84 public ICollection<string> Keys { get { lock (m_map) { return m_map.Keys; } } }
85 public ICollection<OSD> Values { get { lock (m_map) { return m_map.Values; } } }
86 public OSD this[string key]
87 {
88 get
89 {
90 OSD llsd;
91
92 lock (m_map)
93 {
94 if (m_map.TryGetValue(key, out llsd))
95 return llsd;
96 else
97 return null;
98 }
99 }
100 set { lock (m_map) { m_map[key] = value; } }
101 }
102
103 public bool ContainsKey(string key)
104 {
105 lock (m_map)
106 return m_map.ContainsKey(key);
107 }
108
109 public void Add(string key, OSD llsd)
110 {
111 lock (m_map)
112 m_map.Add(key, llsd);
113 }
114
115 public void Add(KeyValuePair<string, OSD> kvp)
116 {
117 lock (m_map)
118 m_map.Add(kvp.Key, kvp.Value);
119 }
120
121 public bool Remove(string key)
122 {
123 lock (m_map)
124 return m_map.Remove(key);
125 }
126
127 public bool TryGetValue(string key, out OSD llsd)
128 {
129 lock (m_map)
130 return m_map.TryGetValue(key, out llsd);
131 }
132
133 public void Clear()
134 {
135 lock (m_map)
136 m_map.Clear();
137 }
138
139 public bool Contains(KeyValuePair<string, OSD> kvp)
140 {
141 lock (m_map)
142 return m_map.ContainsKey(kvp.Key);
143 }
144
145 public void CopyTo(KeyValuePair<string, OSD>[] array, int index)
146 {
147 throw new NotImplementedException();
148 }
149
150 public bool Remove(KeyValuePair<string, OSD> kvp)
151 {
152 lock (m_map)
153 return m_map.Remove(kvp.Key);
154 }
155
156 public System.Collections.IDictionaryEnumerator GetEnumerator()
157 {
158 lock (m_map)
159 return m_map.GetEnumerator();
160 }
161
162 IEnumerator<KeyValuePair<string, OSD>> IEnumerable<KeyValuePair<string, OSD>>.GetEnumerator()
163 {
164 return null;
165 }
166
167 IEnumerator IEnumerable.GetEnumerator()
168 {
169 lock (m_map)
170 return m_map.GetEnumerator();
171 }
172 }
173} \ No newline at end of file
diff --git a/OpenSim/Framework/DynAttrsOSDMap.cs b/OpenSim/Framework/DynAttrsOSDMap.cs
deleted file mode 100644
index 2d45f66..0000000
--- a/OpenSim/Framework/DynAttrsOSDMap.cs
+++ /dev/null
@@ -1,79 +0,0 @@
1/*
2 * Copyright (c) Contributors, http://opensimulator.org/
3 * See CONTRIBUTORS.TXT for a full list of copyright holders.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 * * Neither the name of the OpenSimulator Project nor the
13 * names of its contributors may be used to endorse or promote products
14 * derived from this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27
28using System;
29using System.Collections.Generic;
30using System.IO;
31using System.Text;
32using System.Xml;
33using System.Xml.Schema;
34using System.Xml.Serialization;
35using OpenMetaverse;
36using OpenMetaverse.StructuredData;
37
38namespace OpenSim.Framework
39{
40 /// <summary>
41 /// This is the map for storing and retrieving dynamic attributes.
42 /// </summary>
43 public class DynAttrsOSDMap : OSDMap, IXmlSerializable
44 {
45 public XmlSchema GetSchema() { return null; }
46
47 public static DynAttrsOSDMap FromXml(string rawXml)
48 {
49 DynAttrsOSDMap map = new DynAttrsOSDMap();
50 map.ReadXml(rawXml);
51 return map;
52 }
53
54 public void ReadXml(string rawXml)
55 {
56 //System.Console.WriteLine("Trying to deserialize [{0}]", rawXml);
57
58 OSDMap map = (OSDMap)OSDParser.DeserializeLLSDXml(rawXml);
59
60 foreach (string key in map.Keys)
61 this[key] = map[key];
62 }
63
64 public void ReadXml(XmlReader reader)
65 {
66 ReadXml(reader.ReadInnerXml());
67 }
68
69 public string ToXml()
70 {
71 return OSDParser.SerializeLLSDXmlString(this);
72 }
73
74 public void WriteXml(XmlWriter writer)
75 {
76 writer.WriteRaw(ToXml());
77 }
78 }
79} \ No newline at end of file
diff --git a/OpenSim/Framework/PrimitiveBaseShape.cs b/OpenSim/Framework/PrimitiveBaseShape.cs
index fb0255b..775412b 100644
--- a/OpenSim/Framework/PrimitiveBaseShape.cs
+++ b/OpenSim/Framework/PrimitiveBaseShape.cs
@@ -86,7 +86,7 @@ namespace OpenSim.Framework
86 /// <summary> 86 /// <summary>
87 /// Dynamic attributes can be created and deleted as required. 87 /// Dynamic attributes can be created and deleted as required.
88 /// </summary> 88 /// </summary>
89 public DynAttrsOSDMap DynAttrs { get; set; } 89 public DAMap DynAttrs { get; set; }
90 90
91 private byte[] m_textureEntry; 91 private byte[] m_textureEntry;
92 92
@@ -199,7 +199,7 @@ namespace OpenSim.Framework
199 { 199 {
200 PCode = (byte)PCodeEnum.Primitive; 200 PCode = (byte)PCodeEnum.Primitive;
201 m_textureEntry = DEFAULT_TEXTURE; 201 m_textureEntry = DEFAULT_TEXTURE;
202 DynAttrs = new DynAttrsOSDMap(); 202 DynAttrs = new DAMap();
203 } 203 }
204 204
205 /// <summary> 205 /// <summary>
@@ -211,7 +211,7 @@ namespace OpenSim.Framework
211// m_log.DebugFormat("[PRIMITIVE BASE SHAPE]: Creating from {0}", prim.ID); 211// m_log.DebugFormat("[PRIMITIVE BASE SHAPE]: Creating from {0}", prim.ID);
212 212
213 PCode = (byte)prim.PrimData.PCode; 213 PCode = (byte)prim.PrimData.PCode;
214 DynAttrs = new DynAttrsOSDMap(); 214 DynAttrs = new DAMap();
215 215
216 State = prim.PrimData.State; 216 State = prim.PrimData.State;
217 PathBegin = Primitive.PackBeginCut(prim.PrimData.PathBegin); 217 PathBegin = Primitive.PackBeginCut(prim.PrimData.PathBegin);
diff --git a/OpenSim/Region/CoreModules/Framework/DynamicAttributes/DAExampleModule.cs b/OpenSim/Region/CoreModules/Framework/DynamicAttributes/DAExampleModule.cs
index 2aca93a..d6fb15b 100644
--- a/OpenSim/Region/CoreModules/Framework/DynamicAttributes/DAExampleModule.cs
+++ b/OpenSim/Region/CoreModules/Framework/DynamicAttributes/DAExampleModule.cs
@@ -76,7 +76,7 @@ namespace OpenSim.Region.Framework.DynamicAttributes.DAExampleModule
76 protected bool OnSceneGroupMove(UUID groupId, Vector3 delta) 76 protected bool OnSceneGroupMove(UUID groupId, Vector3 delta)
77 { 77 {
78 SceneObjectPart sop = m_scene.GetSceneObjectPart(groupId); 78 SceneObjectPart sop = m_scene.GetSceneObjectPart(groupId);
79 OSDMap attrs = sop.DynAttrs; 79 DAMap attrs = sop.DynAttrs;
80 80
81 lock (attrs) 81 lock (attrs)
82 { 82 {
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs
index 2a9b99e..27f3a4d 100644
--- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs
@@ -128,7 +128,7 @@ namespace OpenSim.Region.Framework.Scenes
128 /// <summary> 128 /// <summary>
129 /// Dynamic attributes can be created and deleted as required. 129 /// Dynamic attributes can be created and deleted as required.
130 /// </summary> 130 /// </summary>
131 public DynAttrsOSDMap DynAttrs { get; set; } 131 public DAMap DynAttrs { get; set; }
132 132
133 /// <value> 133 /// <value>
134 /// Is this a root part? 134 /// Is this a root part?
@@ -341,7 +341,7 @@ namespace OpenSim.Region.Framework.Scenes
341 m_particleSystem = Utils.EmptyBytes; 341 m_particleSystem = Utils.EmptyBytes;
342 Rezzed = DateTime.UtcNow; 342 Rezzed = DateTime.UtcNow;
343 Description = String.Empty; 343 Description = String.Empty;
344 DynAttrs = new DynAttrsOSDMap(); 344 DynAttrs = new DAMap();
345 345
346 // Prims currently only contain a single folder (Contents). From looking at the Second Life protocol, 346 // Prims currently only contain a single folder (Contents). From looking at the Second Life protocol,
347 // this appears to have the same UUID (!) as the prim. If this isn't the case, one can't drag items from 347 // this appears to have the same UUID (!) as the prim. If this isn't the case, one can't drag items from