OpenSim
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Events Macros
MockRegionDataPlugin.cs
Go to the documentation of this file.
1 /*
2  * Copyright (c) Contributors, http://opensimulator.org/
3  * See CONTRIBUTORS.TXT for a full list of copyright holders.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions are met:
7  * * Redistributions of source code must retain the above copyright
8  * notice, this list of conditions and the following disclaimer.
9  * * Redistributions in binary form must reproduce the above copyright
10  * notice, this list of conditions and the following disclaimer in the
11  * documentation and/or other materials provided with the distribution.
12  * * Neither the name of the OpenSimulator Project nor the
13  * names of its contributors may be used to endorse or promote products
14  * derived from this software without specific prior written permission.
15  *
16  * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
17  * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19  * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20  * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23  * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26  */
27 
28 using System.Reflection;
29 using System.Collections.Generic;
30 using log4net;
31 using OpenMetaverse;
32 using OpenSim.Framework;
33 using OpenSim.Region.Framework.Interfaces;
34 using OpenSim.Region.Framework.Scenes;
35 
36 namespace OpenSim.Data.Null
37 {
39  {
40  private NullDataStore m_store;
41 
42  public NullDataService()
43  {
44  m_store = new NullDataStore();
45  }
46 
47  public void StoreObject(SceneObjectGroup obj, UUID regionUUID)
48  {
49  m_store.StoreObject(obj, regionUUID);
50  }
51 
52  public void RemoveObject(UUID uuid, UUID regionUUID)
53  {
54  m_store.RemoveObject(uuid, regionUUID);
55  }
56 
57  public void StorePrimInventory(UUID primID, ICollection<TaskInventoryItem> items)
58  {
59  m_store.StorePrimInventory(primID, items);
60  }
61 
62  public List<SceneObjectGroup> LoadObjects(UUID regionUUID)
63  {
64  return m_store.LoadObjects(regionUUID);
65  }
66 
67  public void StoreTerrain(double[,] terrain, UUID regionID)
68  {
69  m_store.StoreTerrain(terrain, regionID);
70  }
71 
72  public void StoreTerrain(TerrainData terrain, UUID regionID)
73  {
74  m_store.StoreTerrain(terrain, regionID);
75  }
76 
77  public double[,] LoadTerrain(UUID regionID)
78  {
79  return m_store.LoadTerrain(regionID);
80  }
81 
82  public TerrainData LoadTerrain(UUID regionID, int pSizeX, int pSizeY, int pSizeZ)
83  {
84  return m_store.LoadTerrain(regionID, pSizeX, pSizeY, pSizeZ);
85  }
86 
87  public void StoreLandObject(ILandObject Parcel)
88  {
89  m_store.StoreLandObject(Parcel);
90  }
91 
92  public void RemoveLandObject(UUID globalID)
93  {
94  m_store.RemoveLandObject(globalID);
95  }
96 
97  public List<LandData> LoadLandObjects(UUID regionUUID)
98  {
99  return m_store.LoadLandObjects(regionUUID);
100  }
101 
103  {
104  m_store.StoreRegionSettings(rs);
105  }
106 
107  public RegionSettings LoadRegionSettings(UUID regionUUID)
108  {
109  return m_store.LoadRegionSettings(regionUUID);
110  }
111 
113  {
114  return m_store.LoadRegionWindlightSettings(regionUUID);
115  }
116 
117  public void RemoveRegionWindlightSettings(UUID regionID)
118  {
119  }
120 
122  {
123  m_store.StoreRegionWindlightSettings(wl);
124  }
125 
126  public string LoadRegionEnvironmentSettings(UUID regionUUID)
127  {
128  return m_store.LoadRegionEnvironmentSettings(regionUUID);
129  }
130 
131  public void StoreRegionEnvironmentSettings(UUID regionUUID, string settings)
132  {
133  m_store.StoreRegionEnvironmentSettings(regionUUID, settings);
134  }
135 
136  public void RemoveRegionEnvironmentSettings(UUID regionUUID)
137  {
138  m_store.RemoveRegionEnvironmentSettings(regionUUID);
139  }
140 
141  public UUID[] GetObjectIDs(UUID regionID)
142  {
143  return new UUID[0];
144  }
145 
146  public void SaveExtra(UUID regionID, string name, string value)
147  {
148  }
149 
150  public void RemoveExtra(UUID regionID, string name)
151  {
152  }
153 
154  public Dictionary<string, string> GetExtra(UUID regionID)
155  {
156  return null;
157  }
158  }
159 
165  {
166 // private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
167 
168  protected Dictionary<UUID, RegionSettings> m_regionSettings = new Dictionary<UUID, RegionSettings>();
169  protected Dictionary<UUID, SceneObjectPart> m_sceneObjectParts = new Dictionary<UUID, SceneObjectPart>();
170  protected Dictionary<UUID, ICollection<TaskInventoryItem>> m_primItems
171  = new Dictionary<UUID, ICollection<TaskInventoryItem>>();
172  protected Dictionary<UUID, TerrainData> m_terrains = new Dictionary<UUID, TerrainData>();
173  protected Dictionary<UUID, LandData> m_landData = new Dictionary<UUID, LandData>();
174 
175  public void Initialise(string dbfile)
176  {
177  return;
178  }
179 
180  public void Dispose()
181  {
182  }
183 
185  {
186  m_regionSettings[rs.RegionUUID] = rs;
187  }
188 
190  {
191  //This connector doesn't support the windlight module yet
192  //Return default LL windlight settings
193  return new RegionLightShareData();
194  }
195 
196  public void RemoveRegionWindlightSettings(UUID regionID)
197  {
198  }
199 
201  {
202  //This connector doesn't support the windlight module yet
203  }
204 
205  #region Environment Settings
206  public string LoadRegionEnvironmentSettings(UUID regionUUID)
207  {
208  //This connector doesn't support the Environment module yet
209  return string.Empty;
210  }
211 
212  public void StoreRegionEnvironmentSettings(UUID regionUUID, string settings)
213  {
214  //This connector doesn't support the Environment module yet
215  }
216 
217  public void RemoveRegionEnvironmentSettings(UUID regionUUID)
218  {
219  //This connector doesn't support the Environment module yet
220  }
221  #endregion
222 
223  public RegionSettings LoadRegionSettings(UUID regionUUID)
224  {
225  RegionSettings rs = null;
226  m_regionSettings.TryGetValue(regionUUID, out rs);
227 
228  if (rs == null)
229  rs = new RegionSettings();
230 
231  return rs;
232  }
233 
234  public void StoreObject(SceneObjectGroup obj, UUID regionUUID)
235  {
236  // We can't simply store groups here because on delinking, OpenSim will not update the original group
237  // directly. Rather, the newly delinked parts will be updated to be in their own scene object group
238  // Therefore, we need to store parts rather than groups.
239  foreach (SceneObjectPart prim in obj.Parts)
240  {
241 // m_log.DebugFormat(
242 // "[MOCK REGION DATA PLUGIN]: Storing part {0} {1} in object {2} {3} in region {4}",
243 // prim.Name, prim.UUID, obj.Name, obj.UUID, regionUUID);
244 
245  m_sceneObjectParts[prim.UUID] = prim;
246  }
247  }
248 
249  public void RemoveObject(UUID obj, UUID regionUUID)
250  {
251  // All parts belonging to the object with the uuid are removed.
252  List<SceneObjectPart> parts = new List<SceneObjectPart>(m_sceneObjectParts.Values);
253  foreach (SceneObjectPart part in parts)
254  {
255  if (part.ParentGroup.UUID == obj)
256  {
257 // m_log.DebugFormat(
258 // "[MOCK REGION DATA PLUGIN]: Removing part {0} {1} as part of object {2} from {3}",
259 // part.Name, part.UUID, obj, regionUUID);
260  m_sceneObjectParts.Remove(part.UUID);
261  }
262  }
263  }
264 
265  public void StorePrimInventory(UUID primID, ICollection<TaskInventoryItem> items)
266  {
267  m_primItems[primID] = items;
268  }
269 
270  public List<SceneObjectGroup> LoadObjects(UUID regionUUID)
271  {
272  Dictionary<UUID, SceneObjectGroup> objects = new Dictionary<UUID, SceneObjectGroup>();
273 
274  // Create all of the SOGs from the root prims first
275  foreach (SceneObjectPart prim in m_sceneObjectParts.Values)
276  {
277  if (prim.IsRoot)
278  {
279 // m_log.DebugFormat(
280 // "[MOCK REGION DATA PLUGIN]: Loading root part {0} {1} in {2}", prim.Name, prim.UUID, regionUUID);
281  objects[prim.UUID] = new SceneObjectGroup(prim);
282  }
283  }
284 
285  // Add all of the children objects to the SOGs
286  foreach (SceneObjectPart prim in m_sceneObjectParts.Values)
287  {
288  SceneObjectGroup sog;
289  if (prim.UUID != prim.ParentUUID)
290  {
291  if (objects.TryGetValue(prim.ParentUUID, out sog))
292  {
293  int originalLinkNum = prim.LinkNum;
294 
295  sog.AddPart(prim);
296 
297  // SceneObjectGroup.AddPart() tries to be smart and automatically set the LinkNum.
298  // We override that here
299  if (originalLinkNum != 0)
300  prim.LinkNum = originalLinkNum;
301  }
302  else
303  {
304 // m_log.WarnFormat(
305 // "[MOCK REGION DATA PLUGIN]: Database contains an orphan child prim {0} {1} in region {2} pointing to missing parent {3}. This prim will not be loaded.",
306 // prim.Name, prim.UUID, regionUUID, prim.ParentUUID);
307  }
308  }
309  }
310 
311  // TODO: Load items. This is assymetric - we store items as a separate method but don't retrieve them that
312  // way!
313 
314  return new List<SceneObjectGroup>(objects.Values);
315  }
316 
317  public void StoreTerrain(TerrainData ter, UUID regionID)
318  {
319  m_terrains[regionID] = ter;
320  }
321 
322  public void StoreTerrain(double[,] ter, UUID regionID)
323  {
324  m_terrains[regionID] = new HeightmapTerrainData(ter);
325  }
326 
327  public TerrainData LoadTerrain(UUID regionID, int pSizeX, int pSizeY, int pSizeZ)
328  {
329  if (m_terrains.ContainsKey(regionID))
330  return m_terrains[regionID];
331  else
332  return null;
333  }
334 
335  public double[,] LoadTerrain(UUID regionID)
336  {
337  if (m_terrains.ContainsKey(regionID))
338  return m_terrains[regionID].GetDoubles();
339  else
340  return null;
341  }
342 
343  public void RemoveLandObject(UUID globalID)
344  {
345  if (m_landData.ContainsKey(globalID))
346  m_landData.Remove(globalID);
347  }
348 
349  public void StoreLandObject(ILandObject land)
350  {
351  m_landData[land.LandData.GlobalID] = land.LandData;
352  }
353 
354  public List<LandData> LoadLandObjects(UUID regionUUID)
355  {
356  return new List<LandData>(m_landData.Values);
357  }
358 
359  public void Shutdown()
360  {
361  }
362 
363  public UUID[] GetObjectIDs(UUID regionID)
364  {
365  return new UUID[0];
366  }
367 
368  public void SaveExtra(UUID regionID, string name, string value)
369  {
370  }
371 
372  public void RemoveExtra(UUID regionID, string name)
373  {
374  }
375 
376  public Dictionary<string, string> GetExtra(UUID regionID)
377  {
378  return null;
379  }
380  }
381 }
void SaveExtra(UUID regionID, string name, string value)
void Dispose()
Dispose the database
void StoreRegionWindlightSettings(RegionLightShareData wl)
Mock region data plugin. This obeys the api contract for persistence but stores everything in memory...
Dictionary< string, string > GetExtra(UUID regionID)
TerrainData LoadTerrain(UUID regionID, int pSizeX, int pSizeY, int pSizeZ)
Load the latest terrain revision from region storage
List< SceneObjectGroup > LoadObjects(UUID regionUUID)
Load persisted objects from region storage.
RegionSettings LoadRegionSettings(UUID regionUUID)
void StoreLandObject(ILandObject land)
OpenSim.Framework.RegionSettings RegionSettings
void RemoveExtra(UUID regionID, string name)
A scene object group is conceptually an object in the scene. The object is constituted of SceneObject...
void StorePrimInventory(UUID primID, ICollection< TaskInventoryItem > items)
Store a prim's inventory
void RemoveExtra(UUID regionID, string name)
void StoreTerrain(TerrainData ter, UUID regionID)
Store a terrain revision in region storage
void RemoveObject(UUID uuid, UUID regionUUID)
Entirely removes the object, including inventory
void StoreTerrain(double[,] terrain, UUID regionID)
RegionLightShareData LoadRegionWindlightSettings(UUID regionUUID)
void SaveExtra(UUID regionID, string name, string value)
void StoreObject(SceneObjectGroup obj, UUID regionUUID)
Stores all object's details apart from inventory
void RemoveRegionWindlightSettings(UUID regionID)
void StoreRegionEnvironmentSettings(UUID regionUUID, string settings)
Store Environment settings into region storage
void RemoveRegionEnvironmentSettings(UUID regionUUID)
Delete Environment settings from region storage
void StoreLandObject(ILandObject Parcel)
double[,] LoadTerrain(UUID regionID)
List< SceneObjectGroup > LoadObjects(UUID regionUUID)
Load persisted objects from region storage.
Dictionary< string, string > GetExtra(UUID regionID)
void StoreTerrain(double[,] ter, UUID regionID)
void RemoveLandObject(UUID globalID)
delete from land where UUID=globalID delete from landaccesslist where LandUUID=globalID ...
void StoreTerrain(TerrainData terrain, UUID regionID)
Store a terrain revision in region storage
RegionLightShareData LoadRegionWindlightSettings(UUID regionUUID)
void RemoveRegionWindlightSettings(UUID regionID)
List< LandData > LoadLandObjects(UUID regionUUID)
void RemoveLandObject(UUID globalID)
delete from land where UUID=globalID delete from landaccesslist where LandUUID=globalID ...
void StoreRegionEnvironmentSettings(UUID regionUUID, string settings)
Store Environment settings into region storage
void StoreObject(SceneObjectGroup obj, UUID regionUUID)
Stores all object's details apart from inventory
string LoadRegionEnvironmentSettings(UUID regionUUID)
Load Environment settings from region storage
void StoreRegionSettings(RegionSettings rs)
void Initialise(string dbfile)
Initialises the data storage engine
double[,] LoadTerrain(UUID regionID)
RegionSettings LoadRegionSettings(UUID regionUUID)
void RemoveRegionEnvironmentSettings(UUID regionUUID)
Delete Environment settings from region storage
TerrainData LoadTerrain(UUID regionID, int pSizeX, int pSizeY, int pSizeZ)
Load the latest terrain revision from region storage
void StorePrimInventory(UUID primID, ICollection< TaskInventoryItem > items)
Store a prim's inventory
string LoadRegionEnvironmentSettings(UUID regionUUID)
Load Environment settings from region storage
void StoreRegionSettings(RegionSettings rs)
void StoreRegionWindlightSettings(RegionLightShareData wl)
void RemoveObject(UUID obj, UUID regionUUID)
Entirely removes the object, including inventory
List< LandData > LoadLandObjects(UUID regionUUID)