aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Environment/Scenes/EntityManager.cs
diff options
context:
space:
mode:
authorJeff Ames2008-11-25 16:00:55 +0000
committerJeff Ames2008-11-25 16:00:55 +0000
commit518a8b9f2ac09a5060e2e59c913dfbe7faf397ef (patch)
tree8b3e39fbd54452e031873d31ff099e7db064cdee /OpenSim/Region/Environment/Scenes/EntityManager.cs
parent* minor: eliminate mono compiler warnings (diff)
downloadopensim-SC_OLD-518a8b9f2ac09a5060e2e59c913dfbe7faf397ef.zip
opensim-SC_OLD-518a8b9f2ac09a5060e2e59c913dfbe7faf397ef.tar.gz
opensim-SC_OLD-518a8b9f2ac09a5060e2e59c913dfbe7faf397ef.tar.bz2
opensim-SC_OLD-518a8b9f2ac09a5060e2e59c913dfbe7faf397ef.tar.xz
Update svn properties.
Diffstat (limited to '')
-rw-r--r--OpenSim/Region/Environment/Scenes/EntityManager.cs364
1 files changed, 182 insertions, 182 deletions
diff --git a/OpenSim/Region/Environment/Scenes/EntityManager.cs b/OpenSim/Region/Environment/Scenes/EntityManager.cs
index be39878..eb29ead 100644
--- a/OpenSim/Region/Environment/Scenes/EntityManager.cs
+++ b/OpenSim/Region/Environment/Scenes/EntityManager.cs
@@ -1,182 +1,182 @@
1using System; 1using System;
2using System.Collections; 2using System.Collections;
3using System.Collections.Generic; 3using System.Collections.Generic;
4using OpenMetaverse; 4using OpenMetaverse;
5 5
6namespace OpenSim.Region.Environment.Scenes 6namespace OpenSim.Region.Environment.Scenes
7{ 7{
8 public class EntityManager : IEnumerable<EntityBase> 8 public class EntityManager : IEnumerable<EntityBase>
9 { 9 {
10 private readonly Dictionary<UUID,EntityBase> m_eb_uuid = new Dictionary<UUID, EntityBase>(); 10 private readonly Dictionary<UUID,EntityBase> m_eb_uuid = new Dictionary<UUID, EntityBase>();
11 private readonly Dictionary<uint, EntityBase> m_eb_localID = new Dictionary<uint, EntityBase>(); 11 private readonly Dictionary<uint, EntityBase> m_eb_localID = new Dictionary<uint, EntityBase>();
12 private readonly Object m_lock = new Object(); 12 private readonly Object m_lock = new Object();
13 13
14 [Obsolete("Use Add() instead.")] 14 [Obsolete("Use Add() instead.")]
15 public void Add(UUID id, EntityBase eb) 15 public void Add(UUID id, EntityBase eb)
16 { 16 {
17 Add(eb); 17 Add(eb);
18 } 18 }
19 19
20 public void Add(EntityBase entity) 20 public void Add(EntityBase entity)
21 { 21 {
22 lock(m_lock) 22 lock(m_lock)
23 { 23 {
24 m_eb_uuid.Add(entity.UUID, entity); 24 m_eb_uuid.Add(entity.UUID, entity);
25 m_eb_localID.Add(entity.LocalId, entity); 25 m_eb_localID.Add(entity.LocalId, entity);
26 } 26 }
27 } 27 }
28 28
29 public void InsertOrReplace(EntityBase entity) 29 public void InsertOrReplace(EntityBase entity)
30 { 30 {
31 lock(m_lock) 31 lock(m_lock)
32 { 32 {
33 m_eb_uuid[entity.UUID] = entity; 33 m_eb_uuid[entity.UUID] = entity;
34 m_eb_localID[entity.LocalId] = entity; 34 m_eb_localID[entity.LocalId] = entity;
35 } 35 }
36 } 36 }
37 37
38 public void Clear() 38 public void Clear()
39 { 39 {
40 lock (m_lock) 40 lock (m_lock)
41 { 41 {
42 m_eb_uuid.Clear(); 42 m_eb_uuid.Clear();
43 m_eb_localID.Clear(); 43 m_eb_localID.Clear();
44 } 44 }
45 } 45 }
46 46
47 public int Count 47 public int Count
48 { 48 {
49 get 49 get
50 { 50 {
51 lock (m_lock) 51 lock (m_lock)
52 { 52 {
53 return m_eb_uuid.Count; 53 return m_eb_uuid.Count;
54 } 54 }
55 } 55 }
56 } 56 }
57 57
58 public bool ContainsKey(UUID id) 58 public bool ContainsKey(UUID id)
59 { 59 {
60 lock(m_lock) 60 lock(m_lock)
61 { 61 {
62 return m_eb_uuid.ContainsKey(id); 62 return m_eb_uuid.ContainsKey(id);
63 } 63 }
64 } 64 }
65 65
66 public bool ContainsKey(uint localID) 66 public bool ContainsKey(uint localID)
67 { 67 {
68 lock (m_lock) 68 lock (m_lock)
69 { 69 {
70 return m_eb_localID.ContainsKey(localID); 70 return m_eb_localID.ContainsKey(localID);
71 } 71 }
72 } 72 }
73 73
74 public bool Remove(uint localID) 74 public bool Remove(uint localID)
75 { 75 {
76 lock(m_lock) 76 lock(m_lock)
77 { 77 {
78 bool a = m_eb_uuid.Remove(m_eb_localID[localID].UUID); 78 bool a = m_eb_uuid.Remove(m_eb_localID[localID].UUID);
79 bool b = m_eb_localID.Remove(localID); 79 bool b = m_eb_localID.Remove(localID);
80 80
81 return a && b; 81 return a && b;
82 } 82 }
83 } 83 }
84 84
85 public bool Remove(UUID id) 85 public bool Remove(UUID id)
86 { 86 {
87 lock(m_lock) 87 lock(m_lock)
88 { 88 {
89 bool a = m_eb_localID.Remove(m_eb_uuid[id].LocalId); 89 bool a = m_eb_localID.Remove(m_eb_uuid[id].LocalId);
90 bool b = m_eb_uuid.Remove(id); 90 bool b = m_eb_uuid.Remove(id);
91 91
92 return a && b; 92 return a && b;
93 } 93 }
94 } 94 }
95 95
96 public List<EntityBase> GetAllByType<T>() 96 public List<EntityBase> GetAllByType<T>()
97 { 97 {
98 List<EntityBase> tmp = new List<EntityBase>(); 98 List<EntityBase> tmp = new List<EntityBase>();
99 99
100 lock(m_lock) 100 lock(m_lock)
101 { 101 {
102 foreach (KeyValuePair<UUID, EntityBase> pair in m_eb_uuid) 102 foreach (KeyValuePair<UUID, EntityBase> pair in m_eb_uuid)
103 { 103 {
104 if(pair.Value is T) 104 if(pair.Value is T)
105 { 105 {
106 tmp.Add(pair.Value); 106 tmp.Add(pair.Value);
107 } 107 }
108 } 108 }
109 } 109 }
110 110
111 return tmp; 111 return tmp;
112 } 112 }
113 113
114 public List<EntityBase> GetEntities() 114 public List<EntityBase> GetEntities()
115 { 115 {
116 lock (m_lock) 116 lock (m_lock)
117 { 117 {
118 return new List<EntityBase>(m_eb_uuid.Values); 118 return new List<EntityBase>(m_eb_uuid.Values);
119 } 119 }
120 } 120 }
121 121
122 public EntityBase this[UUID id] 122 public EntityBase this[UUID id]
123 { 123 {
124 get 124 get
125 { 125 {
126 lock (m_lock) 126 lock (m_lock)
127 { 127 {
128 return m_eb_uuid[id]; 128 return m_eb_uuid[id];
129 } 129 }
130 } 130 }
131 set 131 set
132 { 132 {
133 InsertOrReplace(value); 133 InsertOrReplace(value);
134 } 134 }
135 } 135 }
136 136
137 public EntityBase this[uint localID] 137 public EntityBase this[uint localID]
138 { 138 {
139 get 139 get
140 { 140 {
141 lock (m_lock) 141 lock (m_lock)
142 { 142 {
143 return m_eb_localID[localID]; 143 return m_eb_localID[localID];
144 } 144 }
145 } 145 }
146 set 146 set
147 { 147 {
148 InsertOrReplace(value); 148 InsertOrReplace(value);
149 } 149 }
150 } 150 }
151 151
152 public bool TryGetValue(UUID key, out EntityBase obj) 152 public bool TryGetValue(UUID key, out EntityBase obj)
153 { 153 {
154 lock(m_lock) 154 lock(m_lock)
155 { 155 {
156 return m_eb_uuid.TryGetValue(key, out obj); 156 return m_eb_uuid.TryGetValue(key, out obj);
157 } 157 }
158 } 158 }
159 159
160 public bool TryGetValue(uint key, out EntityBase obj) 160 public bool TryGetValue(uint key, out EntityBase obj)
161 { 161 {
162 lock (m_lock) 162 lock (m_lock)
163 { 163 {
164 return m_eb_localID.TryGetValue(key, out obj); 164 return m_eb_localID.TryGetValue(key, out obj);
165 } 165 }
166 } 166 }
167 167
168 /// <summary> 168 /// <summary>
169 /// This could be optimised to work on the list 'live' rather than making a safe copy and iterating that. 169 /// This could be optimised to work on the list 'live' rather than making a safe copy and iterating that.
170 /// </summary> 170 /// </summary>
171 /// <returns></returns> 171 /// <returns></returns>
172 public IEnumerator<EntityBase> GetEnumerator() 172 public IEnumerator<EntityBase> GetEnumerator()
173 { 173 {
174 return GetEntities().GetEnumerator(); 174 return GetEntities().GetEnumerator();
175 } 175 }
176 176
177 IEnumerator IEnumerable.GetEnumerator() 177 IEnumerator IEnumerable.GetEnumerator()
178 { 178 {
179 return GetEnumerator(); 179 return GetEnumerator();
180 } 180 }
181 } 181 }
182} 182}