* refactor: move bottom part of 'xml2' serializaton to separate class

0.6.5-rc1
Justin Clarke Casey 2009-05-14 18:08:54 +00:00
parent d10b5e29bc
commit 303aa4b65e
7 changed files with 70 additions and 73 deletions

View File

@ -66,7 +66,6 @@ namespace OpenSim.ApplicationPlugins.LoadRegions
protected OpenSimBase m_openSim; protected OpenSimBase m_openSim;
public void Initialise() public void Initialise()
{ {
m_log.Info("[LOADREGIONS]: " + Name + " cannot be default-initialized!"); m_log.Info("[LOADREGIONS]: " + Name + " cannot be default-initialized!");

View File

@ -34,7 +34,6 @@ namespace OpenSim.Framework
{ {
UUID UUID { get; } UUID UUID { get; }
ISceneObject CloneForNewScene(); ISceneObject CloneForNewScene();
void ToXml2(XmlTextWriter writer);
string ExtraToXmlString(); string ExtraToXmlString();
void ExtraFromXmlString(string xmlstr); void ExtraFromXmlString(string xmlstr);
string GetStateSnapshot(); string GetStateSnapshot();

View File

@ -220,7 +220,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectors.Interregion
* Object-related communications * Object-related communications
*/ */
public bool SendCreateObject(ulong regionHandle, ISceneObject sog, bool isLocalCall) public bool SendCreateObject(ulong regionHandle, SceneObjectGroup sog, bool isLocalCall)
{ {
foreach (Scene s in m_sceneList) foreach (Scene s in m_sceneList)
{ {

View File

@ -261,7 +261,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectors.Interregion
* Object-related communications * Object-related communications
*/ */
public bool SendCreateObject(ulong regionHandle, ISceneObject sog, bool isLocalCall) public bool SendCreateObject(ulong regionHandle, SceneObjectGroup sog, bool isLocalCall)
{ {
// Try local first // Try local first
if (m_localBackend.SendCreateObject(regionHandle, sog, true)) if (m_localBackend.SendCreateObject(regionHandle, sog, true))

View File

@ -35,7 +35,6 @@ namespace OpenSim.Region.Framework.Interfaces
public interface IInterregionCommsOut public interface IInterregionCommsOut
{ {
#region Agents #region Agents
bool SendCreateChildAgent(ulong regionHandle, AgentCircuitData aCircuit, out string reason); bool SendCreateChildAgent(ulong regionHandle, AgentCircuitData aCircuit, out string reason);
@ -87,7 +86,7 @@ namespace OpenSim.Region.Framework.Interfaces
/// <param name="sog"></param> /// <param name="sog"></param>
/// <param name="isLocalCall"></param> /// <param name="isLocalCall"></param>
/// <returns></returns> /// <returns></returns>
bool SendCreateObject(ulong regionHandle, ISceneObject sog, bool isLocalCall); bool SendCreateObject(ulong regionHandle, SceneObjectGroup sog, bool isLocalCall);
/// <summary> /// <summary>
/// Create an object from the user's inventory in the destination region. /// Create an object from the user's inventory in the destination region.

View File

@ -583,33 +583,6 @@ namespace OpenSim.Region.Framework.Scenes
#endregion #endregion
public void ToXml2(XmlTextWriter writer)
{
//m_log.DebugFormat("[SOG]: Starting serialization of SOG {0} to XML2", Name);
//int time = System.Environment.TickCount;
writer.WriteStartElement(String.Empty, "SceneObjectGroup", String.Empty);
m_rootPart.ToXml(writer);
writer.WriteStartElement(String.Empty, "OtherParts", String.Empty);
lock (m_parts)
{
foreach (SceneObjectPart part in m_parts.Values)
{
if (part.UUID != m_rootPart.UUID)
{
part.ToXml(writer);
}
}
}
writer.WriteEndElement(); // End of OtherParts
SaveScriptedState(writer);
writer.WriteEndElement(); // End of SceneObjectGroup
//m_log.DebugFormat("[SOG]: Finished serialization of SOG {0} to XML2, {1}ms", Name, System.Environment.TickCount - time);
}
public void SaveScriptedState(XmlTextWriter writer) public void SaveScriptedState(XmlTextWriter writer)
{ {
XmlDocument doc = new XmlDocument(); XmlDocument doc = new XmlDocument();

View File

@ -132,10 +132,59 @@ namespace OpenSim.Region.Framework.Scenes.Serialization
} }
/// <summary> /// <summary>
/// Deserialize a scene object from the 'xml2' format /// Serialize a scene object to the original xml format
/// </summary> /// </summary>
/// <param name="serialization"></param> /// <param name="sceneObject"></param>
/// <returns></returns> /// <returns></returns>
public static string ToOriginalXmlFormat(SceneObjectGroup sceneObject)
{
using (StringWriter sw = new StringWriter())
{
using (XmlTextWriter writer = new XmlTextWriter(sw))
{
ToOriginalXmlFormat(sceneObject, writer);
}
return sw.ToString();
}
}
/// <summary>
/// Serialize a scene object to the original xml format
/// </summary>
/// <param name="sceneObject"></param>
/// <returns></returns>
public static void ToOriginalXmlFormat(SceneObjectGroup sceneObject, XmlTextWriter writer)
{
//m_log.DebugFormat("[SERIALIZER]: Starting serialization of {0}", Name);
//int time = System.Environment.TickCount;
writer.WriteStartElement(String.Empty, "SceneObjectGroup", String.Empty);
writer.WriteStartElement(String.Empty, "RootPart", String.Empty);
sceneObject.RootPart.ToXml(writer);
writer.WriteEndElement();
writer.WriteStartElement(String.Empty, "OtherParts", String.Empty);
lock (sceneObject.Children)
{
foreach (SceneObjectPart part in sceneObject.Children.Values)
{
if (part.UUID != sceneObject.RootPart.UUID)
{
writer.WriteStartElement(String.Empty, "Part", String.Empty);
part.ToXml(writer);
writer.WriteEndElement();
}
}
}
writer.WriteEndElement(); // OtherParts
sceneObject.SaveScriptedState(writer);
writer.WriteEndElement(); // SceneObjectGroup
//m_log.DebugFormat("[SERIALIZER]: Finished serialization of SOG {0}, {1}ms", Name, System.Environment.TickCount - time);
}
public static SceneObjectGroup FromXml2Format(string xmlData) public static SceneObjectGroup FromXml2Format(string xmlData)
{ {
//m_log.DebugFormat("[SOG]: Starting deserialization of SOG"); //m_log.DebugFormat("[SOG]: Starting deserialization of SOG");
@ -196,17 +245,17 @@ namespace OpenSim.Region.Framework.Scenes.Serialization
} }
/// <summary> /// <summary>
/// Serialize a scene object to the original xml format /// Serialize a scene object to the 'xml2' format.
/// </summary> /// </summary>
/// <param name="sceneObject"></param> /// <param name="sceneObject"></param>
/// <returns></returns> /// <returns></returns>
public static string ToOriginalXmlFormat(SceneObjectGroup sceneObject) public static string ToXml2Format(SceneObjectGroup sceneObject)
{ {
using (StringWriter sw = new StringWriter()) using (StringWriter sw = new StringWriter())
{ {
using (XmlTextWriter writer = new XmlTextWriter(sw)) using (XmlTextWriter writer = new XmlTextWriter(sw))
{ {
ToOriginalXmlFormat(sceneObject, writer); ToXml2Format(sceneObject, writer);
} }
return sw.ToString(); return sw.ToString();
@ -214,19 +263,17 @@ namespace OpenSim.Region.Framework.Scenes.Serialization
} }
/// <summary> /// <summary>
/// Serialize a scene object to the original xml format /// Serialize a scene object to the 'xml2' format.
/// </summary> /// </summary>
/// <param name="sceneObject"></param> /// <param name="sceneObject"></param>
/// <returns></returns> /// <returns></returns>
public static void ToOriginalXmlFormat(SceneObjectGroup sceneObject, XmlTextWriter writer) public static void ToXml2Format(SceneObjectGroup sceneObject, XmlTextWriter writer)
{ {
//m_log.DebugFormat("[SERIALIZER]: Starting serialization of {0}", Name); //m_log.DebugFormat("[SERIALIZER]: Starting serialization of SOG {0} to XML2", Name);
//int time = System.Environment.TickCount; //int time = System.Environment.TickCount;
writer.WriteStartElement(String.Empty, "SceneObjectGroup", String.Empty); writer.WriteStartElement(String.Empty, "SceneObjectGroup", String.Empty);
writer.WriteStartElement(String.Empty, "RootPart", String.Empty);
sceneObject.RootPart.ToXml(writer); sceneObject.RootPart.ToXml(writer);
writer.WriteEndElement();
writer.WriteStartElement(String.Empty, "OtherParts", String.Empty); writer.WriteStartElement(String.Empty, "OtherParts", String.Empty);
lock (sceneObject.Children) lock (sceneObject.Children)
@ -235,36 +282,16 @@ namespace OpenSim.Region.Framework.Scenes.Serialization
{ {
if (part.UUID != sceneObject.RootPart.UUID) if (part.UUID != sceneObject.RootPart.UUID)
{ {
writer.WriteStartElement(String.Empty, "Part", String.Empty);
part.ToXml(writer); part.ToXml(writer);
writer.WriteEndElement();
} }
} }
} }
writer.WriteEndElement(); // OtherParts writer.WriteEndElement(); // End of OtherParts
sceneObject.SaveScriptedState(writer); sceneObject.SaveScriptedState(writer);
writer.WriteEndElement(); // SceneObjectGroup writer.WriteEndElement(); // End of SceneObjectGroup
//m_log.DebugFormat("[SERIALIZER]: Finished serialization of SOG {0}, {1}ms", Name, System.Environment.TickCount - time); //m_log.DebugFormat("[SERIALIZER]: Finished serialization of SOG {0} to XML2, {1}ms", Name, System.Environment.TickCount - time);
}
/// <summary>
/// Serialize a scene object to the 'xml2' format.
/// </summary>
/// <param name="sceneObject"></param>
/// <returns></returns>
public static string ToXml2Format(ISceneObject sceneObject)
{
using (StringWriter sw = new StringWriter())
{
using (XmlTextWriter writer = new XmlTextWriter(sw))
{
sceneObject.ToXml2(writer);
}
return sw.ToString();
}
} }
} }
} }