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

@@ -44,11 +44,12 @@ namespace OpenSim.Region.CoreModules.Framework.DynamicAttributes.DAExampleModule
[Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "DAExampleModule")]
public class DAExampleModule : INonSharedRegionModule
{
// private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
private static readonly bool ENABLED = false; // enable for testing
private readonly bool ENABLED = false; // enable for testing
public const string DANamespace = "DAExample Module";
public const string Namespace = "Example";
public const string StoreName = "DA";
protected Scene m_scene;
protected IDialogModule m_dialogMod;
@@ -65,6 +66,8 @@ namespace OpenSim.Region.CoreModules.Framework.DynamicAttributes.DAExampleModule
m_scene = scene;
m_scene.EventManager.OnSceneGroupMove += OnSceneGroupMove;
m_dialogMod = m_scene.RequestModuleInterface<IDialogModule>();
m_log.DebugFormat("[DA EXAMPLE MODULE]: Added region {0}", m_scene.Name);
}
}
@@ -91,7 +94,7 @@ namespace OpenSim.Region.CoreModules.Framework.DynamicAttributes.DAExampleModule
if (sop == null)
return true;
if (!sop.DynAttrs.TryGetValue(DANamespace, out attrs))
if (!sop.DynAttrs.TryGetStore(Namespace, StoreName, out attrs))
attrs = new OSDMap();
OSDInteger newValue;
@@ -106,12 +109,14 @@ namespace OpenSim.Region.CoreModules.Framework.DynamicAttributes.DAExampleModule
attrs["moves"] = newValue;
sop.DynAttrs[DANamespace] = attrs;
sop.DynAttrs.SetStore(Namespace, StoreName, attrs);
}
sop.ParentGroup.HasGroupChanged = true;
m_dialogMod.SendGeneralAlert(string.Format("{0} {1} moved {2} times", sop.Name, sop.UUID, newValue));
string msg = string.Format("{0} {1} moved {2} times", sop.Name, sop.UUID, newValue);
m_log.DebugFormat("[DA EXAMPLE MODULE]: {0}", msg);
m_dialogMod.SendGeneralAlert(msg);
return true;
}

View File

@@ -64,8 +64,8 @@ namespace OpenSim.Region.Framework.DynamicAttributes.DOExampleModule
private Scene m_scene;
private IDialogModule m_dialogMod;
public string Name { get { return "DOExample Module"; } }
public string Name { get { return "DO"; } }
public Type ReplaceableInterface { get { return null; } }
public void Initialise(IConfigSource source) {}
@@ -106,7 +106,7 @@ namespace OpenSim.Region.Framework.DynamicAttributes.DOExampleModule
// Console.WriteLine("Here for {0}", so.Name);
if (rootPart.DynAttrs.TryGetValue(DAExampleModule.DANamespace, out attrs))
if (rootPart.DynAttrs.TryGetStore(DAExampleModule.Namespace, DAExampleModule.StoreName, out attrs))
{
movesSoFar = attrs["moves"].AsInteger();
@@ -114,7 +114,7 @@ namespace OpenSim.Region.Framework.DynamicAttributes.DOExampleModule
"[DO EXAMPLE MODULE]: Found saved moves {0} for {1} in {2}", movesSoFar, so.Name, m_scene.Name);
}
rootPart.DynObjs.Add(Name, new MyObject(movesSoFar));
rootPart.DynObjs.Add(DAExampleModule.Namespace, Name, new MyObject(movesSoFar));
}
private bool OnSceneGroupMove(UUID groupId, Vector3 delta)