aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Data
diff options
context:
space:
mode:
authorSean Dague2008-07-07 20:40:14 +0000
committerSean Dague2008-07-07 20:40:14 +0000
commit7634c1311efe82129f18cc8aada1d5f9995b6a9e (patch)
tree732d06d9089216f911b7c1c42bef8285a7fa416f /OpenSim/Data
parentchange SitTarget calls from functions to properties (diff)
downloadopensim-SC_OLD-7634c1311efe82129f18cc8aada1d5f9995b6a9e.zip
opensim-SC_OLD-7634c1311efe82129f18cc8aada1d5f9995b6a9e.tar.gz
opensim-SC_OLD-7634c1311efe82129f18cc8aada1d5f9995b6a9e.tar.bz2
opensim-SC_OLD-7634c1311efe82129f18cc8aada1d5f9995b6a9e.tar.xz
added skeleton (no function) region store component
Diffstat (limited to '')
-rw-r--r--OpenSim/Data/NHibernate/NHibernateRegionData.cs268
1 files changed, 268 insertions, 0 deletions
diff --git a/OpenSim/Data/NHibernate/NHibernateRegionData.cs b/OpenSim/Data/NHibernate/NHibernateRegionData.cs
new file mode 100644
index 0000000..2a2745f
--- /dev/null
+++ b/OpenSim/Data/NHibernate/NHibernateRegionData.cs
@@ -0,0 +1,268 @@
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 OpenSim 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
28using System;
29using System.Collections.Generic;
30using System.IO;
31using System.Reflection;
32using System.Text.RegularExpressions;
33using libsecondlife;
34using log4net;
35using NHibernate;
36using NHibernate.Cfg;
37using NHibernate.Mapping.Attributes;
38using NHibernate.Tool.hbm2ddl;
39using OpenSim.Framework;
40using OpenSim.Region.Environment.Interfaces;
41using OpenSim.Region.Environment.Scenes;
42using Environment=NHibernate.Cfg.Environment;
43
44namespace OpenSim.Data.NHibernate
45{
46 /// <summary>
47 /// A RegionData Interface to the NHibernate database
48 /// </summary>
49 public class NHibernateRegionData : IRegionDataStore
50 {
51 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
52
53 private Configuration cfg;
54 private ISessionFactory factory;
55 private ISession session;
56
57 public void Initialise()
58 {
59 Initialise("SQLiteDialect;SqliteClientDriver;URI=file:OpenSim.db,version=3", true);
60 }
61
62 public void Initialise(string connect, bool persistpriminventories)
63 {
64 // Split out the dialect, driver, and connect string
65 char[] split = {';'};
66 string[] parts = connect.Split(split, 3);
67 if (parts.Length != 3)
68 {
69 // TODO: make this a real exception type
70 throw new Exception("Malformed Inventory connection string '" + connect + "'");
71 }
72
73 string dialect = parts[0];
74
75 // NHibernate setup
76 cfg = new Configuration();
77 cfg.SetProperty(Environment.ConnectionProvider,
78 "NHibernate.Connection.DriverConnectionProvider");
79 cfg.SetProperty(Environment.Dialect,
80 "NHibernate.Dialect." + dialect);
81 cfg.SetProperty(Environment.ConnectionDriver,
82 "NHibernate.Driver." + parts[1]);
83 cfg.SetProperty(Environment.ConnectionString, parts[2]);
84 cfg.AddAssembly("OpenSim.Data.NHibernate");
85
86 HbmSerializer.Default.Validate = true;
87 using (MemoryStream stream =
88 HbmSerializer.Default.Serialize(Assembly.GetExecutingAssembly()))
89 cfg.AddInputStream(stream);
90
91 factory = cfg.BuildSessionFactory();
92 session = factory.OpenSession();
93
94 // This actually does the roll forward assembly stuff
95 Assembly assem = GetType().Assembly;
96 Migration m = new Migration((System.Data.Common.DbConnection)factory.ConnectionProvider.GetConnection(), assem, dialect, "AssetStore");
97 m.Update();
98 }
99
100 /***********************************************************************
101 *
102 * Public Interface Functions
103 *
104 **********************************************************************/
105
106 public void StoreRegionSettings(RegionSettings rs)
107 {
108 }
109
110 public RegionSettings LoadRegionSettings(LLUUID regionUUID)
111 {
112 return null;
113 }
114
115 /// <summary>
116 /// Adds an object into region storage
117 /// </summary>
118 /// <param name="obj">the object</param>
119 /// <param name="regionUUID">the region UUID</param>
120 public void StoreObject(SceneObjectGroup obj, LLUUID regionUUID)
121 {
122
123 }
124
125 /// <summary>
126 /// Removes an object from region storage
127 /// </summary>
128 /// <param name="obj">the object</param>
129 /// <param name="regionUUID">the region UUID</param>
130 public void RemoveObject(LLUUID obj, LLUUID regionUUID)
131 {
132 m_log.InfoFormat("[REGION DB]: Removing obj: {0} from region: {1}", obj.UUID, regionUUID);
133
134 }
135
136 /// <summary>
137 /// Load persisted objects from region storage.
138 /// </summary>
139 /// <param name="regionUUID">The region UUID</param>
140 /// <returns>List of loaded groups</returns>
141 public List<SceneObjectGroup> LoadObjects(LLUUID regionUUID)
142 {
143 List<SceneObjectGroup> prims = new List<SceneObjectGroup>();
144 return prims;
145 }
146
147 /// <summary>
148 /// Store a terrain revision in region storage
149 /// </summary>
150 /// <param name="ter">terrain heightfield</param>
151 /// <param name="regionID">region UUID</param>
152 public void StoreTerrain(double[,] ter, LLUUID regionID)
153 {
154
155 }
156
157 /// <summary>
158 /// Load the latest terrain revision from region storage
159 /// </summary>
160 /// <param name="regionID">the region UUID</param>
161 /// <returns>Heightfield data</returns>
162 public double[,] LoadTerrain(LLUUID regionID)
163 {
164 double[,] terret = new double[256,256];
165 terret.Initialize();
166
167
168 return terret;
169 }
170
171 /// <summary>
172 ///
173 /// </summary>
174 /// <param name="globalID"></param>
175 public void RemoveLandObject(LLUUID globalID)
176 {
177
178 }
179
180 /// <summary>
181 ///
182 /// </summary>
183 /// <param name="parcel"></param>
184 public void StoreLandObject(ILandObject parcel)
185 {
186
187 }
188
189 /// <summary>
190 ///
191 /// </summary>
192 /// <param name="regionUUID"></param>
193 /// <returns></returns>
194 public List<LandData> LoadLandObjects(LLUUID regionUUID)
195 {
196 List<LandData> landDataForRegion = new List<LandData>();
197
198 return landDataForRegion;
199 }
200
201
202 /// <summary>
203 /// See <see cref="Commit"/>
204 /// </summary>
205 public void Shutdown()
206 {
207
208 }
209
210 /// <summary>
211 /// Load a region banlist
212 /// </summary>
213 /// <param name="regionUUID">the region UUID</param>
214 /// <returns>The banlist</returns>
215 public List<RegionBanListItem> LoadRegionBanList(LLUUID regionUUID)
216 {
217 List<RegionBanListItem> regionbanlist = new List<RegionBanListItem>();
218
219 return regionbanlist;
220 }
221
222 /// <summary>
223 /// Add en entry into region banlist
224 /// </summary>
225 /// <param name="item"></param>
226 public void AddToRegionBanlist(RegionBanListItem item)
227 {
228
229 }
230
231 /// <summary>
232 /// remove an entry from the region banlist
233 /// </summary>
234 /// <param name="item"></param>
235 public void RemoveFromRegionBanlist(RegionBanListItem item)
236 {
237
238 }
239
240 /// <summary>
241 ///
242 /// </summary>
243 /// <param name="val"></param>
244 /// <returns></returns>
245 private static Array serializeTerrain(double[,] val)
246 {
247 MemoryStream str = new MemoryStream(65536*sizeof (double));
248 BinaryWriter bw = new BinaryWriter(str);
249
250 // TODO: COMPATIBILITY - Add byte-order conversions
251 for (int x = 0; x < 256; x++)
252 for (int y = 0; y < 256; y++)
253 bw.Write(val[x, y]);
254
255 return str.ToArray();
256 }
257
258 /// <summary>
259 /// see IRegionDatastore
260 /// </summary>
261 /// <param name="primID"></param>
262 /// <param name="items"></param>
263 public void StorePrimInventory(LLUUID primID, ICollection<TaskInventoryItem> items)
264 {
265
266 }
267 }
268}