aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim.Storage/LocalStorageDb4o/Db4LocalStorage.cs
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim.Storage/LocalStorageDb4o/Db4LocalStorage.cs')
-rw-r--r--OpenSim.Storage/LocalStorageDb4o/Db4LocalStorage.cs126
1 files changed, 126 insertions, 0 deletions
diff --git a/OpenSim.Storage/LocalStorageDb4o/Db4LocalStorage.cs b/OpenSim.Storage/LocalStorageDb4o/Db4LocalStorage.cs
new file mode 100644
index 0000000..93ed9cc
--- /dev/null
+++ b/OpenSim.Storage/LocalStorageDb4o/Db4LocalStorage.cs
@@ -0,0 +1,126 @@
1/*
2* Copyright (c) OpenSim project, http://sim.opensecondlife.org/
3*
4* Redistribution and use in source and binary forms, with or without
5* modification, are permitted provided that the following conditions are met:
6* * Redistributions of source code must retain the above copyright
7* notice, this list of conditions and the following disclaimer.
8* * Redistributions in binary form must reproduce the above copyright
9* notice, this list of conditions and the following disclaimer in the
10* documentation and/or other materials provided with the distribution.
11* * Neither the name of the <organization> nor the
12* names of its contributors may be used to endorse or promote products
13* derived from this software without specific prior written permission.
14*
15* THIS SOFTWARE IS PROVIDED BY <copyright holder> ``AS IS'' AND ANY
16* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
17* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
18* DISCLAIMED. IN NO EVENT SHALL <copyright holder> BE LIABLE FOR ANY
19* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
20* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
21* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
22* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
24* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25*
26*/
27using System;
28using System.Collections.Generic;
29using Db4objects.Db4o;
30using Db4objects.Db4o.Query;
31using libsecondlife;
32using OpenSim.Framework.Interfaces;
33using OpenSim.Framework.Assets;
34
35namespace OpenSim.Storage.LocalStorageDb4o
36{
37 /// <summary>
38 ///
39 /// </summary>
40 public class Db4LocalStorage : ILocalStorage
41 {
42 private IObjectContainer db;
43
44 public Db4LocalStorage()
45 {
46 try
47 {
48 db = Db4oFactory.OpenFile("localworld.yap");
49 OpenSim.Framework.Console.MainConsole.Instance.WriteLine("Db4LocalStorage creation");
50 }
51 catch(Exception e)
52 {
53 db.Close();
54 OpenSim.Framework.Console.MainConsole.Instance.WriteLine("Db4LocalStorage :Constructor - Exception occured");
55 OpenSim.Framework.Console.MainConsole.Instance.WriteLine(e.ToString());
56 }
57 }
58
59 public void StorePrim(PrimData prim)
60 {
61 IObjectSet result = db.Query(new UUIDQuery(prim.FullID));
62 if(result.Count>0)
63 {
64 //prim already in storage
65 //so update it
66 PrimData found = (PrimData) result.Next();
67 found.PathBegin = prim.PathBegin;
68 found.PathCurve= prim.PathCurve;
69 found.PathEnd = prim.PathEnd;
70 found.PathRadiusOffset = prim.PathRadiusOffset;
71 found.PathRevolutions = prim.PathRevolutions;
72 found.PathScaleX= prim.PathScaleX;
73 found.PathScaleY = prim.PathScaleY;
74 found.PathShearX = prim.PathShearX;
75 found.PathShearY = prim.PathShearY;
76 found.PathSkew = prim.PathSkew;
77 found.PathTaperX = prim.PathTaperX;
78 found.PathTaperY = prim.PathTaperY;
79 found.PathTwist = prim.PathTwist;
80 found.PathTwistBegin = prim.PathTwistBegin;
81 found.PCode = prim.PCode;
82 found.ProfileBegin = prim.ProfileBegin;
83 found.ProfileCurve = prim.ProfileCurve;
84 found.ProfileEnd = prim.ProfileEnd;
85 found.ProfileHollow = prim.ProfileHollow;
86 found.Position = prim.Position;
87 found.Rotation = prim.Rotation;
88 found.Texture = prim.Texture;
89 db.Set(found);
90 db.Commit();
91 }
92 else
93 {
94 //not in storage
95 db.Set(prim);
96 db.Commit();
97 }
98 }
99
100 public void RemovePrim(LLUUID primID)
101 {
102 IObjectSet result = db.Query(new UUIDQuery(primID));
103 if(result.Count>0)
104 {
105 PrimData found = (PrimData) result.Next();
106 db.Delete(found);
107 }
108 }
109
110
111 public void LoadPrimitives(ILocalStorageReceiver receiver)
112 {
113 IObjectSet result = db.Get(typeof(PrimData));
114 OpenSim.Framework.Console.MainConsole.Instance.WriteLine("Db4LocalStorage.cs: LoadPrimitives() - number of prims in storages is "+result.Count);
115 foreach (PrimData prim in result) {
116 receiver.PrimFromStorage(prim);
117 }
118 }
119
120 public void ShutDown()
121 {
122 db.Commit();
123 db.Close();
124 }
125 }
126}