aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Data/Null
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Data/Null')
-rw-r--r--OpenSim/Data/Null/NullRegionData.cs40
1 files changed, 31 insertions, 9 deletions
diff --git a/OpenSim/Data/Null/NullRegionData.cs b/OpenSim/Data/Null/NullRegionData.cs
index 9d09af7..deb50cb 100644
--- a/OpenSim/Data/Null/NullRegionData.cs
+++ b/OpenSim/Data/Null/NullRegionData.cs
@@ -40,24 +40,40 @@ namespace OpenSim.Data.Null
40 { 40 {
41 private static NullRegionData Instance = null; 41 private static NullRegionData Instance = null;
42 42
43 /// <summary>
44 /// Should we use the static instance for all invocations?
45 /// </summary>
46 private bool m_useStaticInstance = true;
47
43// private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 48// private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
44 49
45 Dictionary<UUID, RegionData> m_regionData = new Dictionary<UUID, RegionData>(); 50 Dictionary<UUID, RegionData> m_regionData = new Dictionary<UUID, RegionData>();
46 51
47 public NullRegionData(string connectionString, string realm) 52 public NullRegionData(string connectionString, string realm)
48 { 53 {
49 if (Instance == null) 54// m_log.DebugFormat(
55// "[NULL REGION DATA]: Constructor got connectionString {0}, realm {1}", connectionString, realm);
56
57 // The !static connection string is a hack so that regression tests can use this module without a high degree of fragility
58 // in having to deal with the static reference in the once-loaded NullRegionData class.
59 //
60 // In standalone operation, we have to use only one instance of this class since the login service and
61 // simulator have no other way of using a common data store.
62 if (connectionString == "!static")
63 m_useStaticInstance = false;
64 else if (Instance == null)
50 Instance = this; 65 Instance = this;
51 //Console.WriteLine("[XXX] NullRegionData constructor");
52 } 66 }
53 67
54 private delegate bool Matcher(string value); 68 private delegate bool Matcher(string value);
55 69
56 public List<RegionData> Get(string regionName, UUID scopeID) 70 public List<RegionData> Get(string regionName, UUID scopeID)
57 { 71 {
58 if (Instance != this) 72 if (m_useStaticInstance && Instance != this)
59 return Instance.Get(regionName, scopeID); 73 return Instance.Get(regionName, scopeID);
60 74
75// m_log.DebugFormat("[NULL REGION DATA]: Getting region {0}, scope {1}", regionName, scopeID);
76
61 string cleanName = regionName.ToLower(); 77 string cleanName = regionName.ToLower();
62 78
63 // Handle SQL wildcards 79 // Handle SQL wildcards
@@ -82,6 +98,7 @@ namespace OpenSim.Data.Null
82 cleanName = cleanName.Remove(cleanName.Length - 1); 98 cleanName = cleanName.Remove(cleanName.Length - 1);
83 } 99 }
84 } 100 }
101
85 Matcher queryMatch; 102 Matcher queryMatch;
86 if (wildcardPrefix && wildcardSuffix) 103 if (wildcardPrefix && wildcardSuffix)
87 queryMatch = delegate(string s) { return s.Contains(cleanName); }; 104 queryMatch = delegate(string s) { return s.Contains(cleanName); };
@@ -110,7 +127,7 @@ namespace OpenSim.Data.Null
110 127
111 public RegionData Get(int posX, int posY, UUID scopeID) 128 public RegionData Get(int posX, int posY, UUID scopeID)
112 { 129 {
113 if (Instance != this) 130 if (m_useStaticInstance && Instance != this)
114 return Instance.Get(posX, posY, scopeID); 131 return Instance.Get(posX, posY, scopeID);
115 132
116 List<RegionData> ret = new List<RegionData>(); 133 List<RegionData> ret = new List<RegionData>();
@@ -129,7 +146,7 @@ namespace OpenSim.Data.Null
129 146
130 public RegionData Get(UUID regionID, UUID scopeID) 147 public RegionData Get(UUID regionID, UUID scopeID)
131 { 148 {
132 if (Instance != this) 149 if (m_useStaticInstance && Instance != this)
133 return Instance.Get(regionID, scopeID); 150 return Instance.Get(regionID, scopeID);
134 151
135 if (m_regionData.ContainsKey(regionID)) 152 if (m_regionData.ContainsKey(regionID))
@@ -140,7 +157,7 @@ namespace OpenSim.Data.Null
140 157
141 public List<RegionData> Get(int startX, int startY, int endX, int endY, UUID scopeID) 158 public List<RegionData> Get(int startX, int startY, int endX, int endY, UUID scopeID)
142 { 159 {
143 if (Instance != this) 160 if (m_useStaticInstance && Instance != this)
144 return Instance.Get(startX, startY, endX, endY, scopeID); 161 return Instance.Get(startX, startY, endX, endY, scopeID);
145 162
146 List<RegionData> ret = new List<RegionData>(); 163 List<RegionData> ret = new List<RegionData>();
@@ -156,9 +173,12 @@ namespace OpenSim.Data.Null
156 173
157 public bool Store(RegionData data) 174 public bool Store(RegionData data)
158 { 175 {
159 if (Instance != this) 176 if (m_useStaticInstance && Instance != this)
160 return Instance.Store(data); 177 return Instance.Store(data);
161 178
179// m_log.DebugFormat(
180// "[NULL REGION DATA]: Storing region {0} {1}, scope {2}", data.RegionName, data.RegionID, data.ScopeID);
181
162 m_regionData[data.RegionID] = data; 182 m_regionData[data.RegionID] = data;
163 183
164 return true; 184 return true;
@@ -166,7 +186,7 @@ namespace OpenSim.Data.Null
166 186
167 public bool SetDataItem(UUID regionID, string item, string value) 187 public bool SetDataItem(UUID regionID, string item, string value)
168 { 188 {
169 if (Instance != this) 189 if (m_useStaticInstance && Instance != this)
170 return Instance.SetDataItem(regionID, item, value); 190 return Instance.SetDataItem(regionID, item, value);
171 191
172 if (!m_regionData.ContainsKey(regionID)) 192 if (!m_regionData.ContainsKey(regionID))
@@ -179,9 +199,11 @@ namespace OpenSim.Data.Null
179 199
180 public bool Delete(UUID regionID) 200 public bool Delete(UUID regionID)
181 { 201 {
182 if (Instance != this) 202 if (m_useStaticInstance && Instance != this)
183 return Instance.Delete(regionID); 203 return Instance.Delete(regionID);
184 204
205// m_log.DebugFormat("[NULL REGION DATA]: Deleting region {0}", regionID);
206
185 if (!m_regionData.ContainsKey(regionID)) 207 if (!m_regionData.ContainsKey(regionID))
186 return false; 208 return false;
187 209