diff options
author | Sean Dague | 2008-04-02 15:24:31 +0000 |
---|---|---|
committer | Sean Dague | 2008-04-02 15:24:31 +0000 |
commit | c52c68f314c67c76c7181a6d0828f476290fbd66 (patch) | |
tree | 66ab347502892902a096fa985f31b25738eb1381 /OpenSim/Data/DB4o/DB4oGridData.cs | |
parent | reorganizing namespaces to put all the Data stuff into it's own namespace (diff) | |
download | opensim-SC_OLD-c52c68f314c67c76c7181a6d0828f476290fbd66.zip opensim-SC_OLD-c52c68f314c67c76c7181a6d0828f476290fbd66.tar.gz opensim-SC_OLD-c52c68f314c67c76c7181a6d0828f476290fbd66.tar.bz2 opensim-SC_OLD-c52c68f314c67c76c7181a6d0828f476290fbd66.tar.xz |
whole lot more moving
Diffstat (limited to 'OpenSim/Data/DB4o/DB4oGridData.cs')
-rw-r--r-- | OpenSim/Data/DB4o/DB4oGridData.cs | 182 |
1 files changed, 182 insertions, 0 deletions
diff --git a/OpenSim/Data/DB4o/DB4oGridData.cs b/OpenSim/Data/DB4o/DB4oGridData.cs new file mode 100644 index 0000000..31b13e3 --- /dev/null +++ b/OpenSim/Data/DB4o/DB4oGridData.cs | |||
@@ -0,0 +1,182 @@ | |||
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 | |||
28 | using System; | ||
29 | using System.Collections.Generic; | ||
30 | using libsecondlife; | ||
31 | |||
32 | namespace OpenSim.Framework.Data.DB4o | ||
33 | { | ||
34 | /// <summary> | ||
35 | /// A grid server storage mechanism employing the DB4o database system | ||
36 | /// </summary> | ||
37 | internal class DB4oGridData : GridDataBase | ||
38 | { | ||
39 | /// <summary> | ||
40 | /// The database manager object | ||
41 | /// </summary> | ||
42 | private DB4oGridManager manager; | ||
43 | |||
44 | /// <summary> | ||
45 | /// Called when the plugin is first loaded (as constructors are not called) | ||
46 | /// </summary> | ||
47 | override public void Initialise() | ||
48 | { | ||
49 | manager = new DB4oGridManager("gridserver.yap"); | ||
50 | } | ||
51 | |||
52 | /// <summary> | ||
53 | /// Returns a list of regions within the specified ranges | ||
54 | /// </summary> | ||
55 | /// <param name="a">minimum X coordinate</param> | ||
56 | /// <param name="b">minimum Y coordinate</param> | ||
57 | /// <param name="c">maximum X coordinate</param> | ||
58 | /// <param name="d">maximum Y coordinate</param> | ||
59 | /// <returns>An array of region profiles</returns> | ||
60 | override public RegionProfileData[] GetProfilesInRange(uint a, uint b, uint c, uint d) | ||
61 | { | ||
62 | return null; | ||
63 | } | ||
64 | |||
65 | /// <summary> | ||
66 | /// Returns a region located at the specified regionHandle (warning multiple regions may occupy the one spot, first found is returned) | ||
67 | /// </summary> | ||
68 | /// <param name="handle">The handle to search for</param> | ||
69 | /// <returns>A region profile</returns> | ||
70 | override public RegionProfileData GetProfileByHandle(ulong handle) | ||
71 | { | ||
72 | lock (manager.simProfiles) | ||
73 | { | ||
74 | foreach (LLUUID UUID in manager.simProfiles.Keys) | ||
75 | { | ||
76 | if (manager.simProfiles[UUID].regionHandle == handle) | ||
77 | { | ||
78 | return manager.simProfiles[UUID]; | ||
79 | } | ||
80 | } | ||
81 | } | ||
82 | throw new Exception("Unable to find profile with handle (" + handle.ToString() + ")"); | ||
83 | } | ||
84 | |||
85 | /// <summary> | ||
86 | /// Returns a specific region | ||
87 | /// </summary> | ||
88 | /// <param name="uuid">The region ID code</param> | ||
89 | /// <returns>A region profile</returns> | ||
90 | override public RegionProfileData GetProfileByLLUUID(LLUUID uuid) | ||
91 | { | ||
92 | lock (manager.simProfiles) | ||
93 | { | ||
94 | if (manager.simProfiles.ContainsKey(uuid)) | ||
95 | return manager.simProfiles[uuid]; | ||
96 | } | ||
97 | throw new Exception("Unable to find profile with UUID (" + uuid.ToString() + | ||
98 | "). Total Registered Regions: " + manager.simProfiles.Count); | ||
99 | } | ||
100 | |||
101 | override public RegionProfileData GetProfileByString(string regionName) | ||
102 | { | ||
103 | throw new Exception("GetProfileByString Not supported in DB4oGridData"); | ||
104 | //return null; | ||
105 | } | ||
106 | |||
107 | /// <summary> | ||
108 | /// Adds a new specified region to the database | ||
109 | /// </summary> | ||
110 | /// <param name="profile">The profile to add</param> | ||
111 | /// <returns>A dataresponse enum indicating success</returns> | ||
112 | override public DataResponse AddProfile(RegionProfileData profile) | ||
113 | { | ||
114 | lock (manager.simProfiles) | ||
115 | { | ||
116 | if (manager.AddRow(profile)) | ||
117 | { | ||
118 | return DataResponse.RESPONSE_OK; | ||
119 | } | ||
120 | else | ||
121 | { | ||
122 | return DataResponse.RESPONSE_ERROR; | ||
123 | } | ||
124 | } | ||
125 | } | ||
126 | |||
127 | /// <summary> | ||
128 | /// Authenticates a new region using the shared secrets. NOT SECURE. | ||
129 | /// </summary> | ||
130 | /// <param name="uuid">The UUID the region is authenticating with</param> | ||
131 | /// <param name="handle">The location the region is logging into (unused in Db4o)</param> | ||
132 | /// <param name="key">The shared secret</param> | ||
133 | /// <returns>Authenticated?</returns> | ||
134 | override public bool AuthenticateSim(LLUUID uuid, ulong handle, string key) | ||
135 | { | ||
136 | if (manager.simProfiles[uuid].regionRecvKey == key) | ||
137 | return true; | ||
138 | return false; | ||
139 | } | ||
140 | |||
141 | /// <summary> | ||
142 | /// Shuts down the database | ||
143 | /// </summary> | ||
144 | override public void Close() | ||
145 | { | ||
146 | manager = null; | ||
147 | } | ||
148 | |||
149 | /// <summary> | ||
150 | /// // Returns a list of avatar and UUIDs that match the query | ||
151 | /// </summary> | ||
152 | public List<AvatarPickerAvatar> GeneratePickerResults(LLUUID queryID, string query) | ||
153 | { | ||
154 | //Do nothing yet | ||
155 | List<AvatarPickerAvatar> returnlist = new List<AvatarPickerAvatar>(); | ||
156 | return returnlist; | ||
157 | } | ||
158 | |||
159 | /// <summary> | ||
160 | /// Returns the providers name | ||
161 | /// </summary> | ||
162 | /// <returns>The name of the storage system</returns> | ||
163 | override public string getName() | ||
164 | { | ||
165 | return "DB4o Grid Provider"; | ||
166 | } | ||
167 | |||
168 | /// <summary> | ||
169 | /// Returns the providers version | ||
170 | /// </summary> | ||
171 | /// <returns>The version of the storage system</returns> | ||
172 | override public string getVersion() | ||
173 | { | ||
174 | return "0.1"; | ||
175 | } | ||
176 | |||
177 | override public ReservationData GetReservationAtPoint(uint x, uint y) | ||
178 | { | ||
179 | return null; | ||
180 | } | ||
181 | } | ||
182 | } | ||