diff options
Diffstat (limited to 'OpenGridServices/OpenGrid.Framework.Data.DB4o/DB4oManager.cs')
-rw-r--r-- | OpenGridServices/OpenGrid.Framework.Data.DB4o/DB4oManager.cs | 54 |
1 files changed, 54 insertions, 0 deletions
diff --git a/OpenGridServices/OpenGrid.Framework.Data.DB4o/DB4oManager.cs b/OpenGridServices/OpenGrid.Framework.Data.DB4o/DB4oManager.cs index b30f889..408b213 100644 --- a/OpenGridServices/OpenGrid.Framework.Data.DB4o/DB4oManager.cs +++ b/OpenGridServices/OpenGrid.Framework.Data.DB4o/DB4oManager.cs | |||
@@ -1,3 +1,29 @@ | |||
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 THE DEVELOPERS ``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 | */ | ||
1 | using System; | 27 | using System; |
2 | using System.Collections.Generic; | 28 | using System.Collections.Generic; |
3 | using System.Text; | 29 | using System.Text; |
@@ -7,17 +33,31 @@ using libsecondlife; | |||
7 | 33 | ||
8 | namespace OpenGrid.Framework.Data.DB4o | 34 | namespace OpenGrid.Framework.Data.DB4o |
9 | { | 35 | { |
36 | /// <summary> | ||
37 | /// A Database manager for Db4o | ||
38 | /// </summary> | ||
10 | class DB4oGridManager | 39 | class DB4oGridManager |
11 | { | 40 | { |
41 | /// <summary> | ||
42 | /// A list of the current regions connected (in-memory cache) | ||
43 | /// </summary> | ||
12 | public Dictionary<LLUUID, SimProfileData> simProfiles = new Dictionary<LLUUID, SimProfileData>(); | 44 | public Dictionary<LLUUID, SimProfileData> simProfiles = new Dictionary<LLUUID, SimProfileData>(); |
45 | /// <summary> | ||
46 | /// Database File Name | ||
47 | /// </summary> | ||
13 | string dbfl; | 48 | string dbfl; |
14 | 49 | ||
50 | /// <summary> | ||
51 | /// Creates a new grid storage manager | ||
52 | /// </summary> | ||
53 | /// <param name="db4odb">Filename to the database file</param> | ||
15 | public DB4oGridManager(string db4odb) | 54 | public DB4oGridManager(string db4odb) |
16 | { | 55 | { |
17 | dbfl = db4odb; | 56 | dbfl = db4odb; |
18 | IObjectContainer database; | 57 | IObjectContainer database; |
19 | database = Db4oFactory.OpenFile(dbfl); | 58 | database = Db4oFactory.OpenFile(dbfl); |
20 | IObjectSet result = database.Get(typeof(SimProfileData)); | 59 | IObjectSet result = database.Get(typeof(SimProfileData)); |
60 | // Loads the file into the in-memory cache | ||
21 | foreach(SimProfileData row in result) { | 61 | foreach(SimProfileData row in result) { |
22 | simProfiles.Add(row.UUID, row); | 62 | simProfiles.Add(row.UUID, row); |
23 | } | 63 | } |
@@ -57,16 +97,30 @@ namespace OpenGrid.Framework.Data.DB4o | |||
57 | 97 | ||
58 | } | 98 | } |
59 | 99 | ||
100 | /// <summary> | ||
101 | /// A manager for the DB4o database (user profiles) | ||
102 | /// </summary> | ||
60 | class DB4oUserManager | 103 | class DB4oUserManager |
61 | { | 104 | { |
105 | /// <summary> | ||
106 | /// A list of the user profiles (in memory cache) | ||
107 | /// </summary> | ||
62 | public Dictionary<LLUUID, UserProfileData> userProfiles = new Dictionary<LLUUID, UserProfileData>(); | 108 | public Dictionary<LLUUID, UserProfileData> userProfiles = new Dictionary<LLUUID, UserProfileData>(); |
109 | /// <summary> | ||
110 | /// Database filename | ||
111 | /// </summary> | ||
63 | string dbfl; | 112 | string dbfl; |
64 | 113 | ||
114 | /// <summary> | ||
115 | /// Initialises a new DB manager | ||
116 | /// </summary> | ||
117 | /// <param name="db4odb">The filename to the database</param> | ||
65 | public DB4oUserManager(string db4odb) | 118 | public DB4oUserManager(string db4odb) |
66 | { | 119 | { |
67 | dbfl = db4odb; | 120 | dbfl = db4odb; |
68 | IObjectContainer database; | 121 | IObjectContainer database; |
69 | database = Db4oFactory.OpenFile(dbfl); | 122 | database = Db4oFactory.OpenFile(dbfl); |
123 | // Load to cache | ||
70 | IObjectSet result = database.Get(typeof(UserProfileData)); | 124 | IObjectSet result = database.Get(typeof(UserProfileData)); |
71 | foreach (UserProfileData row in result) | 125 | foreach (UserProfileData row in result) |
72 | { | 126 | { |