Make the concept of namespaces explicit in dynamic attributes

This is in order to reduce the likelihood of naming clashes, make it easier to filter in/out attributes, ensure uniformity, etc.
All dynattrs in the opensim distro itself or likely future ones should be in the "OpenSim" namespace.
This does alter the underlying dynattrs data structure.  All data in previous structures may not be available, though old structures should not cause errors.
This is done without notice since this feature has been explicitly labelled as experimental, subject to change and has not been in a release.
However, existing materials data is being preserved by moving it to the "Materials" store in the "OpenSim" namespace.
This commit is contained in:
Justin Clark-Casey (justincc)
2013-06-27 23:14:28 +01:00
parent f78d2ef166
commit f7d09b898a
11 changed files with 270 additions and 185 deletions

View File

@@ -178,7 +178,7 @@ namespace OpenSim.Region.OptionalModules.MaterialsDemoModule
void GetStoredMaterialsForPart(SceneObjectPart part)
{
OSDMap OSMaterials = null;
OSD OSMaterials = null;
OSDArray matsArr = null;
if (part.DynAttrs == null)
@@ -188,23 +188,20 @@ namespace OpenSim.Region.OptionalModules.MaterialsDemoModule
lock (part.DynAttrs)
{
if (part.DynAttrs.ContainsKey("OS:Materials"))
OSMaterials = part.DynAttrs["OS:Materials"];
if (OSMaterials != null && OSMaterials.ContainsKey("Materials"))
if (part.DynAttrs.ContainsStore("OpenSim", "Materials"))
{
OSD osd = OSMaterials["Materials"];
if (osd is OSDArray)
matsArr = osd as OSDArray;
OSDMap materialsStore = part.DynAttrs.GetStore("OpenSim", "Materials");
materialsStore.TryGetValue("Materials", out OSMaterials);
}
if (OSMaterials != null && OSMaterials is OSDArray)
matsArr = OSMaterials as OSDArray;
else
return;
}
if (OSMaterials == null)
return;
m_log.Info("[MaterialsDemoModule]: OSMaterials: " + OSDParser.SerializeJsonString(OSMaterials));
if (matsArr == null)
{
m_log.Info("[MaterialsDemoModule]: matsArr is null :( ");
@@ -215,7 +212,6 @@ namespace OpenSim.Region.OptionalModules.MaterialsDemoModule
{
if (elemOsd != null && elemOsd is OSDMap)
{
OSDMap matMap = elemOsd as OSDMap;
if (matMap.ContainsKey("ID") && matMap.ContainsKey("Material"))
{
@@ -232,7 +228,6 @@ namespace OpenSim.Region.OptionalModules.MaterialsDemoModule
}
}
void StoreMaterialsForPart(SceneObjectPart part)
{
try
@@ -277,7 +272,7 @@ namespace OpenSim.Region.OptionalModules.MaterialsDemoModule
OSMaterials["Materials"] = matsArr;
lock (part.DynAttrs)
part.DynAttrs["OS:Materials"] = OSMaterials;
part.DynAttrs.SetStore("OpenSim", "Materials", OSMaterials);
}
catch (Exception e)
{
@@ -285,7 +280,6 @@ namespace OpenSim.Region.OptionalModules.MaterialsDemoModule
}
}
public string RenderMaterialsPostCap(string request, string path,
string param, IOSHttpRequest httpRequest,
IOSHttpResponse httpResponse)