diff options
author | Melanie | 2009-09-16 18:20:08 +0100 |
---|---|---|
committer | Melanie | 2009-09-16 18:20:08 +0100 |
commit | df7904c58b76eaa4fee771383e26b4b8e75d1abf (patch) | |
tree | d75a04b80fb26283375f5b6c2bb327cfa0f60154 /OpenSim/Data | |
parent | Merge branch 'master' of ssh://melanie@opensimulator.org/var/git/opensim (diff) | |
download | opensim-SC-df7904c58b76eaa4fee771383e26b4b8e75d1abf.zip opensim-SC-df7904c58b76eaa4fee771383e26b4b8e75d1abf.tar.gz opensim-SC-df7904c58b76eaa4fee771383e26b4b8e75d1abf.tar.bz2 opensim-SC-df7904c58b76eaa4fee771383e26b4b8e75d1abf.tar.xz |
Add the Null storage implementation for the RegionData service. Standalones
have no regions table, so this is needed
Diffstat (limited to 'OpenSim/Data')
-rw-r--r-- | OpenSim/Data/Null/NullRegionData.cs | 136 |
1 files changed, 136 insertions, 0 deletions
diff --git a/OpenSim/Data/Null/NullRegionData.cs b/OpenSim/Data/Null/NullRegionData.cs new file mode 100644 index 0000000..588b8ac --- /dev/null +++ b/OpenSim/Data/Null/NullRegionData.cs | |||
@@ -0,0 +1,136 @@ | |||
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 OpenSimulator 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; | ||
30 | using System.Collections.Generic; | ||
31 | using OpenMetaverse; | ||
32 | using OpenSim.Framework; | ||
33 | using OpenSim.Data; | ||
34 | |||
35 | namespace OpenSim.Data.Null | ||
36 | { | ||
37 | public class NullRegionData : IRegionData | ||
38 | { | ||
39 | Dictionary<UUID, RegionData> m_regionData = new Dictionary<UUID, RegionData>(); | ||
40 | |||
41 | public NullRegionData(string connectionString, string realm) | ||
42 | { | ||
43 | } | ||
44 | |||
45 | public List<RegionData> Get(string regionName, UUID scopeID) | ||
46 | { | ||
47 | List<RegionData> ret = new List<RegionData>(); | ||
48 | |||
49 | foreach(RegionData r in m_regionData.Values) | ||
50 | { | ||
51 | if (regionName.Contains("%")) | ||
52 | { | ||
53 | if (r.RegionName.Contains(regionName.Replace("%", ""))) | ||
54 | ret.Add(r); | ||
55 | } | ||
56 | else | ||
57 | { | ||
58 | if (r.RegionName == regionName) | ||
59 | ret.Add(r); | ||
60 | } | ||
61 | } | ||
62 | |||
63 | if (ret.Count > 0) | ||
64 | return ret; | ||
65 | |||
66 | return null; | ||
67 | } | ||
68 | |||
69 | public RegionData Get(int posX, int posY, UUID scopeID) | ||
70 | { | ||
71 | List<RegionData> ret = new List<RegionData>(); | ||
72 | |||
73 | foreach(RegionData r in m_regionData.Values) | ||
74 | { | ||
75 | if (r.posX == posX && r.posY == posY) | ||
76 | ret.Add(r); | ||
77 | } | ||
78 | |||
79 | if (ret.Count > 0) | ||
80 | return ret[0]; | ||
81 | |||
82 | return null; | ||
83 | } | ||
84 | |||
85 | public RegionData Get(UUID regionID, UUID scopeID) | ||
86 | { | ||
87 | if (m_regionData.ContainsKey(regionID)) | ||
88 | return m_regionData[regionID]; | ||
89 | |||
90 | return null; | ||
91 | } | ||
92 | |||
93 | public List<RegionData> Get(int startX, int startY, int endX, int endY, UUID scopeID) | ||
94 | { | ||
95 | List<RegionData> ret = new List<RegionData>(); | ||
96 | |||
97 | foreach(RegionData r in m_regionData.Values) | ||
98 | { | ||
99 | if (r.posX >= startX && r.posX <= endX && r.posY >= startY && r.posY <= endY) | ||
100 | ret.Add(r); | ||
101 | } | ||
102 | |||
103 | if (ret.Count > 0) | ||
104 | return ret; | ||
105 | |||
106 | return null; | ||
107 | } | ||
108 | |||
109 | public bool Store(RegionData data) | ||
110 | { | ||
111 | m_regionData[data.RegionID] = data; | ||
112 | |||
113 | return true; | ||
114 | } | ||
115 | |||
116 | public bool SetDataItem(UUID regionID, string item, string value) | ||
117 | { | ||
118 | if (!m_regionData.ContainsKey(regionID)) | ||
119 | return false; | ||
120 | |||
121 | m_regionData[regionID].Data[item] = value; | ||
122 | |||
123 | return true; | ||
124 | } | ||
125 | |||
126 | public bool Delete(UUID regionID) | ||
127 | { | ||
128 | if (!m_regionData.ContainsKey(regionID)) | ||
129 | return false; | ||
130 | |||
131 | m_regionData.Remove(regionID); | ||
132 | |||
133 | return true; | ||
134 | } | ||
135 | } | ||
136 | } | ||