aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/OptionalModules/Scripting/JsonStore/JsonStore.cs
diff options
context:
space:
mode:
authorMic Bowman2013-02-06 17:29:17 -0800
committerMic Bowman2013-02-06 17:29:17 -0800
commite17392acbb46e1e48e169069a822f8b814762214 (patch)
treec14427ae1cd4c294addbe220e8916d4b9e068e3d /OpenSim/Region/OptionalModules/Scripting/JsonStore/JsonStore.cs
parentBulletSim: remove an exception which occurs if a physics mesh (diff)
downloadopensim-SC_OLD-e17392acbb46e1e48e169069a822f8b814762214.zip
opensim-SC_OLD-e17392acbb46e1e48e169069a822f8b814762214.tar.gz
opensim-SC_OLD-e17392acbb46e1e48e169069a822f8b814762214.tar.bz2
opensim-SC_OLD-e17392acbb46e1e48e169069a822f8b814762214.tar.xz
Enables script access to the per object dynamic attributes through the JsonStore
script functions. Adds JsonAttachObjectStore to associate a store identifier with an object (scripts can only access the store in their host object, this could be extended but isn't necessary for now). Note this opens a method to the DAMap OSDMap. This will be removed later, but greatly simplifies the code for now. The JsonStore and these scripts are disabled by default.
Diffstat (limited to '')
-rw-r--r--OpenSim/Region/OptionalModules/Scripting/JsonStore/JsonStore.cs64
1 files changed, 51 insertions, 13 deletions
diff --git a/OpenSim/Region/OptionalModules/Scripting/JsonStore/JsonStore.cs b/OpenSim/Region/OptionalModules/Scripting/JsonStore/JsonStore.cs
index 0b7b31b..751e463 100644
--- a/OpenSim/Region/OptionalModules/Scripting/JsonStore/JsonStore.cs
+++ b/OpenSim/Region/OptionalModules/Scripting/JsonStore/JsonStore.cs
@@ -49,7 +49,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore
49 private static readonly ILog m_log = 49 private static readonly ILog m_log =
50 LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 50 LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
51 51
52 private OSD m_ValueStore; 52 protected virtual OSD ValueStore { get; set; }
53 53
54 protected class TakeValueCallbackClass 54 protected class TakeValueCallbackClass
55 { 55 {
@@ -108,17 +108,18 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore
108 /// 108 ///
109 /// </summary> 109 /// </summary>
110 // ----------------------------------------------------------------- 110 // -----------------------------------------------------------------
111 public JsonStore() : this("") {} 111 public JsonStore()
112
113 public JsonStore(string value)
114 { 112 {
115 m_TakeStore = new List<TakeValueCallbackClass>(); 113 m_TakeStore = new List<TakeValueCallbackClass>();
116 m_ReadStore = new List<TakeValueCallbackClass>(); 114 m_ReadStore = new List<TakeValueCallbackClass>();
117 115 }
116
117 public JsonStore(string value)
118 {
118 if (String.IsNullOrEmpty(value)) 119 if (String.IsNullOrEmpty(value))
119 m_ValueStore = new OSDMap(); 120 ValueStore = new OSDMap();
120 else 121 else
121 m_ValueStore = OSDParser.DeserializeJson(value); 122 ValueStore = OSDParser.DeserializeJson(value);
122 } 123 }
123 124
124 // ----------------------------------------------------------------- 125 // -----------------------------------------------------------------
@@ -129,7 +130,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore
129 public bool TestPath(string expr, bool useJson) 130 public bool TestPath(string expr, bool useJson)
130 { 131 {
131 Stack<string> path = ParsePathExpression(expr); 132 Stack<string> path = ParsePathExpression(expr);
132 OSD result = ProcessPathExpression(m_ValueStore,path); 133 OSD result = ProcessPathExpression(ValueStore,path);
133 134
134 if (result == null) 135 if (result == null)
135 return false; 136 return false;
@@ -148,7 +149,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore
148 public bool GetValue(string expr, out string value, bool useJson) 149 public bool GetValue(string expr, out string value, bool useJson)
149 { 150 {
150 Stack<string> path = ParsePathExpression(expr); 151 Stack<string> path = ParsePathExpression(expr);
151 OSD result = ProcessPathExpression(m_ValueStore,path); 152 OSD result = ProcessPathExpression(ValueStore,path);
152 return ConvertOutputValue(result,out value,useJson); 153 return ConvertOutputValue(result,out value,useJson);
153 } 154 }
154 155
@@ -184,7 +185,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore
184 Stack<string> path = ParsePathExpression(expr); 185 Stack<string> path = ParsePathExpression(expr);
185 string pexpr = PathExpressionToKey(path); 186 string pexpr = PathExpressionToKey(path);
186 187
187 OSD result = ProcessPathExpression(m_ValueStore,path); 188 OSD result = ProcessPathExpression(ValueStore,path);
188 if (result == null) 189 if (result == null)
189 { 190 {
190 m_TakeStore.Add(new TakeValueCallbackClass(pexpr,useJson,cback)); 191 m_TakeStore.Add(new TakeValueCallbackClass(pexpr,useJson,cback));
@@ -215,7 +216,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore
215 Stack<string> path = ParsePathExpression(expr); 216 Stack<string> path = ParsePathExpression(expr);
216 string pexpr = PathExpressionToKey(path); 217 string pexpr = PathExpressionToKey(path);
217 218
218 OSD result = ProcessPathExpression(m_ValueStore,path); 219 OSD result = ProcessPathExpression(ValueStore,path);
219 if (result == null) 220 if (result == null)
220 { 221 {
221 m_ReadStore.Add(new TakeValueCallbackClass(pexpr,useJson,cback)); 222 m_ReadStore.Add(new TakeValueCallbackClass(pexpr,useJson,cback));
@@ -245,7 +246,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore
245 Stack<string> path = ParsePathExpression(expr); 246 Stack<string> path = ParsePathExpression(expr);
246 if (path.Count == 0) 247 if (path.Count == 0)
247 { 248 {
248 m_ValueStore = ovalue; 249 ValueStore = ovalue;
249 return true; 250 return true;
250 } 251 }
251 252
@@ -254,7 +255,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore
254 if (pexpr != "") 255 if (pexpr != "")
255 pexpr += "."; 256 pexpr += ".";
256 257
257 OSD result = ProcessPathExpression(m_ValueStore,path); 258 OSD result = ProcessPathExpression(ValueStore,path);
258 if (result == null) 259 if (result == null)
259 return false; 260 return false;
260 261
@@ -522,4 +523,41 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore
522 return pkey; 523 return pkey;
523 } 524 }
524 } 525 }
526
527 public class JsonObjectStore : JsonStore
528 {
529 private static readonly ILog m_log =
530 LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
531
532 private Scene m_scene;
533 private UUID m_objectID;
534
535 protected override OSD ValueStore
536 {
537 get
538 {
539 SceneObjectPart sop = m_scene.GetSceneObjectPart(m_objectID);
540 if (sop == null)
541 {
542 // This is bad
543 return null;
544 }
545
546 return sop.DynAttrs.TopLevelMap;
547 }
548
549 // cannot set the top level
550 set
551 {
552 m_log.InfoFormat("[JsonStore] cannot set top level value in object store");
553 }
554 }
555
556 public JsonObjectStore(Scene scene, UUID oid) : base()
557 {
558 m_scene = scene;
559 m_objectID = oid;
560 }
561 }
562
525} 563}