diff options
author | Justin Clarke Casey | 2009-05-14 18:08:54 +0000 |
---|---|---|
committer | Justin Clarke Casey | 2009-05-14 18:08:54 +0000 |
commit | 303aa4b65ead33c44122d61c0f9ef075236e6f76 (patch) | |
tree | 9007de8773b2f33af81ec2530214ecb3ef468db6 /OpenSim | |
parent | * refactor: break some of xml2 serialization out of sog (diff) | |
download | opensim-SC_OLD-303aa4b65ead33c44122d61c0f9ef075236e6f76.zip opensim-SC_OLD-303aa4b65ead33c44122d61c0f9ef075236e6f76.tar.gz opensim-SC_OLD-303aa4b65ead33c44122d61c0f9ef075236e6f76.tar.bz2 opensim-SC_OLD-303aa4b65ead33c44122d61c0f9ef075236e6f76.tar.xz |
* refactor: move bottom part of 'xml2' serializaton to separate class
Diffstat (limited to '')
7 files changed, 70 insertions, 73 deletions
diff --git a/OpenSim/ApplicationPlugins/LoadRegions/LoadRegionsPlugin.cs b/OpenSim/ApplicationPlugins/LoadRegions/LoadRegionsPlugin.cs index a470f04..9416fe5 100644 --- a/OpenSim/ApplicationPlugins/LoadRegions/LoadRegionsPlugin.cs +++ b/OpenSim/ApplicationPlugins/LoadRegions/LoadRegionsPlugin.cs | |||
@@ -66,7 +66,6 @@ namespace OpenSim.ApplicationPlugins.LoadRegions | |||
66 | 66 | ||
67 | protected OpenSimBase m_openSim; | 67 | protected OpenSimBase m_openSim; |
68 | 68 | ||
69 | |||
70 | public void Initialise() | 69 | public void Initialise() |
71 | { | 70 | { |
72 | m_log.Info("[LOADREGIONS]: " + Name + " cannot be default-initialized!"); | 71 | m_log.Info("[LOADREGIONS]: " + Name + " cannot be default-initialized!"); |
diff --git a/OpenSim/Framework/ISceneObject.cs b/OpenSim/Framework/ISceneObject.cs index 2162cb9..14a338e 100644 --- a/OpenSim/Framework/ISceneObject.cs +++ b/OpenSim/Framework/ISceneObject.cs | |||
@@ -32,9 +32,8 @@ namespace OpenSim.Framework | |||
32 | { | 32 | { |
33 | public interface ISceneObject | 33 | public interface ISceneObject |
34 | { | 34 | { |
35 | UUID UUID { get; } | 35 | UUID UUID { get; } |
36 | ISceneObject CloneForNewScene(); | 36 | ISceneObject CloneForNewScene(); |
37 | void ToXml2(XmlTextWriter writer); | ||
38 | string ExtraToXmlString(); | 37 | string ExtraToXmlString(); |
39 | void ExtraFromXmlString(string xmlstr); | 38 | void ExtraFromXmlString(string xmlstr); |
40 | string GetStateSnapshot(); | 39 | string GetStateSnapshot(); |
diff --git a/OpenSim/Region/CoreModules/ServiceConnectors/Interregion/LocalInterregionComms.cs b/OpenSim/Region/CoreModules/ServiceConnectors/Interregion/LocalInterregionComms.cs index bdf2280..98f7085 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectors/Interregion/LocalInterregionComms.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectors/Interregion/LocalInterregionComms.cs | |||
@@ -220,7 +220,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectors.Interregion | |||
220 | * Object-related communications | 220 | * Object-related communications |
221 | */ | 221 | */ |
222 | 222 | ||
223 | public bool SendCreateObject(ulong regionHandle, ISceneObject sog, bool isLocalCall) | 223 | public bool SendCreateObject(ulong regionHandle, SceneObjectGroup sog, bool isLocalCall) |
224 | { | 224 | { |
225 | foreach (Scene s in m_sceneList) | 225 | foreach (Scene s in m_sceneList) |
226 | { | 226 | { |
diff --git a/OpenSim/Region/CoreModules/ServiceConnectors/Interregion/RESTInterregionComms.cs b/OpenSim/Region/CoreModules/ServiceConnectors/Interregion/RESTInterregionComms.cs index 606b47c..08c6e7d 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectors/Interregion/RESTInterregionComms.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectors/Interregion/RESTInterregionComms.cs | |||
@@ -261,7 +261,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectors.Interregion | |||
261 | * Object-related communications | 261 | * Object-related communications |
262 | */ | 262 | */ |
263 | 263 | ||
264 | public bool SendCreateObject(ulong regionHandle, ISceneObject sog, bool isLocalCall) | 264 | public bool SendCreateObject(ulong regionHandle, SceneObjectGroup sog, bool isLocalCall) |
265 | { | 265 | { |
266 | // Try local first | 266 | // Try local first |
267 | if (m_localBackend.SendCreateObject(regionHandle, sog, true)) | 267 | if (m_localBackend.SendCreateObject(regionHandle, sog, true)) |
diff --git a/OpenSim/Region/Framework/Interfaces/IInterregionComms.cs b/OpenSim/Region/Framework/Interfaces/IInterregionComms.cs index 95b1079..34b8aac 100644 --- a/OpenSim/Region/Framework/Interfaces/IInterregionComms.cs +++ b/OpenSim/Region/Framework/Interfaces/IInterregionComms.cs | |||
@@ -35,7 +35,6 @@ namespace OpenSim.Region.Framework.Interfaces | |||
35 | 35 | ||
36 | public interface IInterregionCommsOut | 36 | public interface IInterregionCommsOut |
37 | { | 37 | { |
38 | |||
39 | #region Agents | 38 | #region Agents |
40 | 39 | ||
41 | bool SendCreateChildAgent(ulong regionHandle, AgentCircuitData aCircuit, out string reason); | 40 | bool SendCreateChildAgent(ulong regionHandle, AgentCircuitData aCircuit, out string reason); |
@@ -87,7 +86,7 @@ namespace OpenSim.Region.Framework.Interfaces | |||
87 | /// <param name="sog"></param> | 86 | /// <param name="sog"></param> |
88 | /// <param name="isLocalCall"></param> | 87 | /// <param name="isLocalCall"></param> |
89 | /// <returns></returns> | 88 | /// <returns></returns> |
90 | bool SendCreateObject(ulong regionHandle, ISceneObject sog, bool isLocalCall); | 89 | bool SendCreateObject(ulong regionHandle, SceneObjectGroup sog, bool isLocalCall); |
91 | 90 | ||
92 | /// <summary> | 91 | /// <summary> |
93 | /// Create an object from the user's inventory in the destination region. | 92 | /// Create an object from the user's inventory in the destination region. |
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs index 5611b03..8a06fd1 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs | |||
@@ -583,33 +583,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
583 | 583 | ||
584 | #endregion | 584 | #endregion |
585 | 585 | ||
586 | public void ToXml2(XmlTextWriter writer) | ||
587 | { | ||
588 | //m_log.DebugFormat("[SOG]: Starting serialization of SOG {0} to XML2", Name); | ||
589 | //int time = System.Environment.TickCount; | ||
590 | |||
591 | writer.WriteStartElement(String.Empty, "SceneObjectGroup", String.Empty); | ||
592 | m_rootPart.ToXml(writer); | ||
593 | writer.WriteStartElement(String.Empty, "OtherParts", String.Empty); | ||
594 | |||
595 | lock (m_parts) | ||
596 | { | ||
597 | foreach (SceneObjectPart part in m_parts.Values) | ||
598 | { | ||
599 | if (part.UUID != m_rootPart.UUID) | ||
600 | { | ||
601 | part.ToXml(writer); | ||
602 | } | ||
603 | } | ||
604 | } | ||
605 | |||
606 | writer.WriteEndElement(); // End of OtherParts | ||
607 | SaveScriptedState(writer); | ||
608 | writer.WriteEndElement(); // End of SceneObjectGroup | ||
609 | |||
610 | //m_log.DebugFormat("[SOG]: Finished serialization of SOG {0} to XML2, {1}ms", Name, System.Environment.TickCount - time); | ||
611 | } | ||
612 | |||
613 | public void SaveScriptedState(XmlTextWriter writer) | 586 | public void SaveScriptedState(XmlTextWriter writer) |
614 | { | 587 | { |
615 | XmlDocument doc = new XmlDocument(); | 588 | XmlDocument doc = new XmlDocument(); |
diff --git a/OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs b/OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs index 0ec1922..03a4289 100644 --- a/OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs +++ b/OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs | |||
@@ -129,13 +129,62 @@ namespace OpenSim.Region.Framework.Scenes.Serialization | |||
129 | //m_log.DebugFormat("[SERIALIZER]: Finished deserialization of SOG {0}, {1}ms", Name, System.Environment.TickCount - time); | 129 | //m_log.DebugFormat("[SERIALIZER]: Finished deserialization of SOG {0}, {1}ms", Name, System.Environment.TickCount - time); |
130 | 130 | ||
131 | return sceneObject; | 131 | return sceneObject; |
132 | } | 132 | } |
133 | 133 | ||
134 | /// <summary> | 134 | /// <summary> |
135 | /// Deserialize a scene object from the 'xml2' format | 135 | /// Serialize a scene object to the original xml format |
136 | /// </summary> | 136 | /// </summary> |
137 | /// <param name="serialization"></param> | 137 | /// <param name="sceneObject"></param> |
138 | /// <returns></returns> | 138 | /// <returns></returns> |
139 | public static string ToOriginalXmlFormat(SceneObjectGroup sceneObject) | ||
140 | { | ||
141 | using (StringWriter sw = new StringWriter()) | ||
142 | { | ||
143 | using (XmlTextWriter writer = new XmlTextWriter(sw)) | ||
144 | { | ||
145 | ToOriginalXmlFormat(sceneObject, writer); | ||
146 | } | ||
147 | |||
148 | return sw.ToString(); | ||
149 | } | ||
150 | } | ||
151 | |||
152 | /// <summary> | ||
153 | /// Serialize a scene object to the original xml format | ||
154 | /// </summary> | ||
155 | /// <param name="sceneObject"></param> | ||
156 | /// <returns></returns> | ||
157 | public static void ToOriginalXmlFormat(SceneObjectGroup sceneObject, XmlTextWriter writer) | ||
158 | { | ||
159 | //m_log.DebugFormat("[SERIALIZER]: Starting serialization of {0}", Name); | ||
160 | //int time = System.Environment.TickCount; | ||
161 | |||
162 | writer.WriteStartElement(String.Empty, "SceneObjectGroup", String.Empty); | ||
163 | writer.WriteStartElement(String.Empty, "RootPart", String.Empty); | ||
164 | sceneObject.RootPart.ToXml(writer); | ||
165 | writer.WriteEndElement(); | ||
166 | writer.WriteStartElement(String.Empty, "OtherParts", String.Empty); | ||
167 | |||
168 | lock (sceneObject.Children) | ||
169 | { | ||
170 | foreach (SceneObjectPart part in sceneObject.Children.Values) | ||
171 | { | ||
172 | if (part.UUID != sceneObject.RootPart.UUID) | ||
173 | { | ||
174 | writer.WriteStartElement(String.Empty, "Part", String.Empty); | ||
175 | part.ToXml(writer); | ||
176 | writer.WriteEndElement(); | ||
177 | } | ||
178 | } | ||
179 | } | ||
180 | |||
181 | writer.WriteEndElement(); // OtherParts | ||
182 | sceneObject.SaveScriptedState(writer); | ||
183 | writer.WriteEndElement(); // SceneObjectGroup | ||
184 | |||
185 | //m_log.DebugFormat("[SERIALIZER]: Finished serialization of SOG {0}, {1}ms", Name, System.Environment.TickCount - time); | ||
186 | } | ||
187 | |||
139 | public static SceneObjectGroup FromXml2Format(string xmlData) | 188 | public static SceneObjectGroup FromXml2Format(string xmlData) |
140 | { | 189 | { |
141 | //m_log.DebugFormat("[SOG]: Starting deserialization of SOG"); | 190 | //m_log.DebugFormat("[SOG]: Starting deserialization of SOG"); |
@@ -193,40 +242,38 @@ namespace OpenSim.Region.Framework.Scenes.Serialization | |||
193 | //m_log.DebugFormat("[SERIALIZER]: Finished deserialization of SOG {0}, {1}ms", Name, System.Environment.TickCount - time); | 242 | //m_log.DebugFormat("[SERIALIZER]: Finished deserialization of SOG {0}, {1}ms", Name, System.Environment.TickCount - time); |
194 | 243 | ||
195 | return sceneObject; | 244 | return sceneObject; |
196 | } | 245 | } |
197 | 246 | ||
198 | /// <summary> | 247 | /// <summary> |
199 | /// Serialize a scene object to the original xml format | 248 | /// Serialize a scene object to the 'xml2' format. |
200 | /// </summary> | 249 | /// </summary> |
201 | /// <param name="sceneObject"></param> | 250 | /// <param name="sceneObject"></param> |
202 | /// <returns></returns> | 251 | /// <returns></returns> |
203 | public static string ToOriginalXmlFormat(SceneObjectGroup sceneObject) | 252 | public static string ToXml2Format(SceneObjectGroup sceneObject) |
204 | { | 253 | { |
205 | using (StringWriter sw = new StringWriter()) | 254 | using (StringWriter sw = new StringWriter()) |
206 | { | 255 | { |
207 | using (XmlTextWriter writer = new XmlTextWriter(sw)) | 256 | using (XmlTextWriter writer = new XmlTextWriter(sw)) |
208 | { | 257 | { |
209 | ToOriginalXmlFormat(sceneObject, writer); | 258 | ToXml2Format(sceneObject, writer); |
210 | } | 259 | } |
211 | 260 | ||
212 | return sw.ToString(); | 261 | return sw.ToString(); |
213 | } | 262 | } |
214 | } | 263 | } |
215 | 264 | ||
216 | /// <summary> | 265 | /// <summary> |
217 | /// Serialize a scene object to the original xml format | 266 | /// Serialize a scene object to the 'xml2' format. |
218 | /// </summary> | 267 | /// </summary> |
219 | /// <param name="sceneObject"></param> | 268 | /// <param name="sceneObject"></param> |
220 | /// <returns></returns> | 269 | /// <returns></returns> |
221 | public static void ToOriginalXmlFormat(SceneObjectGroup sceneObject, XmlTextWriter writer) | 270 | public static void ToXml2Format(SceneObjectGroup sceneObject, XmlTextWriter writer) |
222 | { | 271 | { |
223 | //m_log.DebugFormat("[SERIALIZER]: Starting serialization of {0}", Name); | 272 | //m_log.DebugFormat("[SERIALIZER]: Starting serialization of SOG {0} to XML2", Name); |
224 | //int time = System.Environment.TickCount; | 273 | //int time = System.Environment.TickCount; |
225 | 274 | ||
226 | writer.WriteStartElement(String.Empty, "SceneObjectGroup", String.Empty); | 275 | writer.WriteStartElement(String.Empty, "SceneObjectGroup", String.Empty); |
227 | writer.WriteStartElement(String.Empty, "RootPart", String.Empty); | ||
228 | sceneObject.RootPart.ToXml(writer); | 276 | sceneObject.RootPart.ToXml(writer); |
229 | writer.WriteEndElement(); | ||
230 | writer.WriteStartElement(String.Empty, "OtherParts", String.Empty); | 277 | writer.WriteStartElement(String.Empty, "OtherParts", String.Empty); |
231 | 278 | ||
232 | lock (sceneObject.Children) | 279 | lock (sceneObject.Children) |
@@ -235,36 +282,16 @@ namespace OpenSim.Region.Framework.Scenes.Serialization | |||
235 | { | 282 | { |
236 | if (part.UUID != sceneObject.RootPart.UUID) | 283 | if (part.UUID != sceneObject.RootPart.UUID) |
237 | { | 284 | { |
238 | writer.WriteStartElement(String.Empty, "Part", String.Empty); | ||
239 | part.ToXml(writer); | 285 | part.ToXml(writer); |
240 | writer.WriteEndElement(); | ||
241 | } | 286 | } |
242 | } | 287 | } |
243 | } | 288 | } |
244 | 289 | ||
245 | writer.WriteEndElement(); // OtherParts | 290 | writer.WriteEndElement(); // End of OtherParts |
246 | sceneObject.SaveScriptedState(writer); | 291 | sceneObject.SaveScriptedState(writer); |
247 | writer.WriteEndElement(); // SceneObjectGroup | 292 | writer.WriteEndElement(); // End of SceneObjectGroup |
248 | |||
249 | //m_log.DebugFormat("[SERIALIZER]: Finished serialization of SOG {0}, {1}ms", Name, System.Environment.TickCount - time); | ||
250 | } | ||
251 | |||
252 | /// <summary> | ||
253 | /// Serialize a scene object to the 'xml2' format. | ||
254 | /// </summary> | ||
255 | /// <param name="sceneObject"></param> | ||
256 | /// <returns></returns> | ||
257 | public static string ToXml2Format(ISceneObject sceneObject) | ||
258 | { | ||
259 | using (StringWriter sw = new StringWriter()) | ||
260 | { | ||
261 | using (XmlTextWriter writer = new XmlTextWriter(sw)) | ||
262 | { | ||
263 | sceneObject.ToXml2(writer); | ||
264 | } | ||
265 | 293 | ||
266 | return sw.ToString(); | 294 | //m_log.DebugFormat("[SERIALIZER]: Finished serialization of SOG {0} to XML2, {1}ms", Name, System.Environment.TickCount - time); |
267 | } | 295 | } |
268 | } | ||
269 | } | 296 | } |
270 | } | 297 | } |