diff options
author | Sean Dague | 2007-07-16 15:40:11 +0000 |
---|---|---|
committer | Sean Dague | 2007-07-16 15:40:11 +0000 |
commit | 2a3c79df83e800d5dfe75a1a3b140ed81da2b1d6 (patch) | |
tree | e3f80ad51736cf17e856547b1bcf956010927434 /OpenSim/Framework/Data.DB4o/DB4oManager.cs | |
parent | *Trunk compiles now (diff) | |
download | opensim-SC_OLD-2a3c79df83e800d5dfe75a1a3b140ed81da2b1d6.zip opensim-SC_OLD-2a3c79df83e800d5dfe75a1a3b140ed81da2b1d6.tar.gz opensim-SC_OLD-2a3c79df83e800d5dfe75a1a3b140ed81da2b1d6.tar.bz2 opensim-SC_OLD-2a3c79df83e800d5dfe75a1a3b140ed81da2b1d6.tar.xz |
changed to native line ending encoding
Diffstat (limited to '')
-rw-r--r-- | OpenSim/Framework/Data.DB4o/DB4oManager.cs | 326 |
1 files changed, 163 insertions, 163 deletions
diff --git a/OpenSim/Framework/Data.DB4o/DB4oManager.cs b/OpenSim/Framework/Data.DB4o/DB4oManager.cs index 0df6350..43f9095 100644 --- a/OpenSim/Framework/Data.DB4o/DB4oManager.cs +++ b/OpenSim/Framework/Data.DB4o/DB4oManager.cs | |||
@@ -1,163 +1,163 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (c) Contributors, http://www.openmetaverse.org/ | 2 | * Copyright (c) Contributors, http://www.openmetaverse.org/ |
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | 3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. |
4 | * | 4 | * |
5 | * Redistribution and use in source and binary forms, with or without | 5 | * Redistribution and use in source and binary forms, with or without |
6 | * modification, are permitted provided that the following conditions are met: | 6 | * modification, are permitted provided that the following conditions are met: |
7 | * * Redistributions of source code must retain the above copyright | 7 | * * Redistributions of source code must retain the above copyright |
8 | * notice, this list of conditions and the following disclaimer. | 8 | * notice, this list of conditions and the following disclaimer. |
9 | * * Redistributions in binary form must reproduce the above copyright | 9 | * * Redistributions in binary form must reproduce the above copyright |
10 | * notice, this list of conditions and the following disclaimer in the | 10 | * notice, this list of conditions and the following disclaimer in the |
11 | * documentation and/or other materials provided with the distribution. | 11 | * documentation and/or other materials provided with the distribution. |
12 | * * Neither the name of the OpenSim Project nor the | 12 | * * Neither the name of the OpenSim Project nor the |
13 | * names of its contributors may be used to endorse or promote products | 13 | * names of its contributors may be used to endorse or promote products |
14 | * derived from this software without specific prior written permission. | 14 | * derived from this software without specific prior written permission. |
15 | * | 15 | * |
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY | 16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY |
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | 17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | 18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | 19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY |
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | 20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES |
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | 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 | 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 | 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 | 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. | 25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
26 | * | 26 | * |
27 | */ | 27 | */ |
28 | using System; | 28 | using System; |
29 | using System.Collections.Generic; | 29 | using System.Collections.Generic; |
30 | using Db4objects.Db4o; | 30 | using Db4objects.Db4o; |
31 | using libsecondlife; | 31 | using libsecondlife; |
32 | 32 | ||
33 | namespace OpenSim.Framework.Data.DB4o | 33 | namespace OpenSim.Framework.Data.DB4o |
34 | { | 34 | { |
35 | /// <summary> | 35 | /// <summary> |
36 | /// A Database manager for Db4o | 36 | /// A Database manager for Db4o |
37 | /// </summary> | 37 | /// </summary> |
38 | class DB4oGridManager | 38 | class DB4oGridManager |
39 | { | 39 | { |
40 | /// <summary> | 40 | /// <summary> |
41 | /// A list of the current regions connected (in-memory cache) | 41 | /// A list of the current regions connected (in-memory cache) |
42 | /// </summary> | 42 | /// </summary> |
43 | public Dictionary<LLUUID, SimProfileData> simProfiles = new Dictionary<LLUUID, SimProfileData>(); | 43 | public Dictionary<LLUUID, SimProfileData> simProfiles = new Dictionary<LLUUID, SimProfileData>(); |
44 | /// <summary> | 44 | /// <summary> |
45 | /// Database File Name | 45 | /// Database File Name |
46 | /// </summary> | 46 | /// </summary> |
47 | string dbfl; | 47 | string dbfl; |
48 | 48 | ||
49 | /// <summary> | 49 | /// <summary> |
50 | /// Creates a new grid storage manager | 50 | /// Creates a new grid storage manager |
51 | /// </summary> | 51 | /// </summary> |
52 | /// <param name="db4odb">Filename to the database file</param> | 52 | /// <param name="db4odb">Filename to the database file</param> |
53 | public DB4oGridManager(string db4odb) | 53 | public DB4oGridManager(string db4odb) |
54 | { | 54 | { |
55 | dbfl = db4odb; | 55 | dbfl = db4odb; |
56 | IObjectContainer database; | 56 | IObjectContainer database; |
57 | database = Db4oFactory.OpenFile(dbfl); | 57 | database = Db4oFactory.OpenFile(dbfl); |
58 | IObjectSet result = database.Get(typeof(SimProfileData)); | 58 | IObjectSet result = database.Get(typeof(SimProfileData)); |
59 | // Loads the file into the in-memory cache | 59 | // Loads the file into the in-memory cache |
60 | foreach(SimProfileData row in result) { | 60 | foreach(SimProfileData row in result) { |
61 | simProfiles.Add(row.UUID, row); | 61 | simProfiles.Add(row.UUID, row); |
62 | } | 62 | } |
63 | database.Close(); | 63 | database.Close(); |
64 | } | 64 | } |
65 | 65 | ||
66 | /// <summary> | 66 | /// <summary> |
67 | /// Adds a new profile to the database (Warning: Probably slow.) | 67 | /// Adds a new profile to the database (Warning: Probably slow.) |
68 | /// </summary> | 68 | /// </summary> |
69 | /// <param name="row">The profile to add</param> | 69 | /// <param name="row">The profile to add</param> |
70 | /// <returns>Successful?</returns> | 70 | /// <returns>Successful?</returns> |
71 | public bool AddRow(SimProfileData row) | 71 | public bool AddRow(SimProfileData row) |
72 | { | 72 | { |
73 | if (simProfiles.ContainsKey(row.UUID)) | 73 | if (simProfiles.ContainsKey(row.UUID)) |
74 | { | 74 | { |
75 | simProfiles[row.UUID] = row; | 75 | simProfiles[row.UUID] = row; |
76 | } | 76 | } |
77 | else | 77 | else |
78 | { | 78 | { |
79 | simProfiles.Add(row.UUID, row); | 79 | simProfiles.Add(row.UUID, row); |
80 | } | 80 | } |
81 | 81 | ||
82 | try | 82 | try |
83 | { | 83 | { |
84 | IObjectContainer database; | 84 | IObjectContainer database; |
85 | database = Db4oFactory.OpenFile(dbfl); | 85 | database = Db4oFactory.OpenFile(dbfl); |
86 | database.Set(row); | 86 | database.Set(row); |
87 | database.Close(); | 87 | database.Close(); |
88 | return true; | 88 | return true; |
89 | } | 89 | } |
90 | catch (Exception) | 90 | catch (Exception) |
91 | { | 91 | { |
92 | return false; | 92 | return false; |
93 | } | 93 | } |
94 | } | 94 | } |
95 | 95 | ||
96 | 96 | ||
97 | } | 97 | } |
98 | 98 | ||
99 | /// <summary> | 99 | /// <summary> |
100 | /// A manager for the DB4o database (user profiles) | 100 | /// A manager for the DB4o database (user profiles) |
101 | /// </summary> | 101 | /// </summary> |
102 | class DB4oUserManager | 102 | class DB4oUserManager |
103 | { | 103 | { |
104 | /// <summary> | 104 | /// <summary> |
105 | /// A list of the user profiles (in memory cache) | 105 | /// A list of the user profiles (in memory cache) |
106 | /// </summary> | 106 | /// </summary> |
107 | public Dictionary<LLUUID, UserProfileData> userProfiles = new Dictionary<LLUUID, UserProfileData>(); | 107 | public Dictionary<LLUUID, UserProfileData> userProfiles = new Dictionary<LLUUID, UserProfileData>(); |
108 | /// <summary> | 108 | /// <summary> |
109 | /// Database filename | 109 | /// Database filename |
110 | /// </summary> | 110 | /// </summary> |
111 | string dbfl; | 111 | string dbfl; |
112 | 112 | ||
113 | /// <summary> | 113 | /// <summary> |
114 | /// Initialises a new DB manager | 114 | /// Initialises a new DB manager |
115 | /// </summary> | 115 | /// </summary> |
116 | /// <param name="db4odb">The filename to the database</param> | 116 | /// <param name="db4odb">The filename to the database</param> |
117 | public DB4oUserManager(string db4odb) | 117 | public DB4oUserManager(string db4odb) |
118 | { | 118 | { |
119 | dbfl = db4odb; | 119 | dbfl = db4odb; |
120 | IObjectContainer database; | 120 | IObjectContainer database; |
121 | database = Db4oFactory.OpenFile(dbfl); | 121 | database = Db4oFactory.OpenFile(dbfl); |
122 | // Load to cache | 122 | // Load to cache |
123 | IObjectSet result = database.Get(typeof(UserProfileData)); | 123 | IObjectSet result = database.Get(typeof(UserProfileData)); |
124 | foreach (UserProfileData row in result) | 124 | foreach (UserProfileData row in result) |
125 | { | 125 | { |
126 | userProfiles.Add(row.UUID, row); | 126 | userProfiles.Add(row.UUID, row); |
127 | } | 127 | } |
128 | database.Close(); | 128 | database.Close(); |
129 | } | 129 | } |
130 | 130 | ||
131 | /// <summary> | 131 | /// <summary> |
132 | /// Adds a new profile to the database (Warning: Probably slow.) | 132 | /// Adds a new profile to the database (Warning: Probably slow.) |
133 | /// </summary> | 133 | /// </summary> |
134 | /// <param name="row">The profile to add</param> | 134 | /// <param name="row">The profile to add</param> |
135 | /// <returns>Successful?</returns> | 135 | /// <returns>Successful?</returns> |
136 | public bool AddRow(UserProfileData row) | 136 | public bool AddRow(UserProfileData row) |
137 | { | 137 | { |
138 | if (userProfiles.ContainsKey(row.UUID)) | 138 | if (userProfiles.ContainsKey(row.UUID)) |
139 | { | 139 | { |
140 | userProfiles[row.UUID] = row; | 140 | userProfiles[row.UUID] = row; |
141 | } | 141 | } |
142 | else | 142 | else |
143 | { | 143 | { |
144 | userProfiles.Add(row.UUID, row); | 144 | userProfiles.Add(row.UUID, row); |
145 | } | 145 | } |
146 | 146 | ||
147 | try | 147 | try |
148 | { | 148 | { |
149 | IObjectContainer database; | 149 | IObjectContainer database; |
150 | database = Db4oFactory.OpenFile(dbfl); | 150 | database = Db4oFactory.OpenFile(dbfl); |
151 | database.Set(row); | 151 | database.Set(row); |
152 | database.Close(); | 152 | database.Close(); |
153 | return true; | 153 | return true; |
154 | } | 154 | } |
155 | catch (Exception) | 155 | catch (Exception) |
156 | { | 156 | { |
157 | return false; | 157 | return false; |
158 | } | 158 | } |
159 | } | 159 | } |
160 | 160 | ||
161 | 161 | ||
162 | } | 162 | } |
163 | } | 163 | } |