aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Data/Base/AppearanceTableMapper.cs
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--OpenSim/Data/Base/AppearanceTableMapper.cs284
1 files changed, 0 insertions, 284 deletions
diff --git a/OpenSim/Data/Base/AppearanceTableMapper.cs b/OpenSim/Data/Base/AppearanceTableMapper.cs
deleted file mode 100644
index c1bb739..0000000
--- a/OpenSim/Data/Base/AppearanceTableMapper.cs
+++ /dev/null
@@ -1,284 +0,0 @@
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 OpenSim 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
28using System;
29using OpenMetaverse;
30using OpenSim.Data.Base;
31using OpenSim.Framework;
32
33namespace OpenSim.Data.Base
34{
35 /// <summary>
36 ///
37 /// </summary>
38 public class AppearanceRowMapper : BaseRowMapper<AvatarAppearance>
39 {
40 public AppearanceRowMapper(BaseSchema schema, AvatarAppearance obj)
41 : base(schema, obj)
42 {
43 }
44 }
45
46 /// <summary>
47 ///
48 /// </summary>
49 public class AppearanceTableMapper : BaseTableMapper<AppearanceRowMapper, Guid>
50 {
51 public AppearanceTableMapper(BaseDatabaseConnector database, string tableName)
52 : base(database, tableName)
53 {
54 BaseSchema<AppearanceRowMapper> rowMapperSchema = new BaseSchema<AppearanceRowMapper>(this);
55 m_schema = rowMapperSchema;
56
57 m_keyFieldMapper = rowMapperSchema.AddMapping<Guid>("UUID",
58 delegate(AppearanceRowMapper mapper) { return mapper.Object.Owner.Guid; },
59 delegate(AppearanceRowMapper mapper, Guid value) { mapper.Object.Owner = new UUID(value.ToString()); });
60
61 rowMapperSchema.AddMapping<uint>("Serial",
62 delegate(AppearanceRowMapper mapper) { return (uint)mapper.Object.Serial; },
63 delegate(AppearanceRowMapper mapper, uint value) { mapper.Object.Serial = (int)value; });
64
65 rowMapperSchema.AddMapping<Guid>("WearableItem0",
66 delegate(AppearanceRowMapper mapper) { return mapper.Object.Wearables[0].ItemID.Guid; },
67 delegate(AppearanceRowMapper mapper, Guid value)
68 {
69 if (mapper.Object.Wearables == null)
70 {
71 mapper.Object.Wearables = new AvatarWearable[13];
72 for (int i = 0; i < 13; i++)
73 {
74 mapper.Object.Wearables[i] = new AvatarWearable();
75 }
76 }
77 mapper.Object.Wearables[0].ItemID = new UUID(value.ToString());
78 });
79
80 rowMapperSchema.AddMapping<Guid>("WearableAsset0",
81 delegate(AppearanceRowMapper mapper) { return mapper.Object.Wearables[0].AssetID.Guid; },
82 delegate(AppearanceRowMapper mapper, Guid value)
83 { mapper.Object.Wearables[0].AssetID = new UUID(value.ToString()); });
84
85 rowMapperSchema.AddMapping<Guid>("WearableItem1",
86 delegate(AppearanceRowMapper mapper) { return mapper.Object.Wearables[1].ItemID.Guid; },
87 delegate(AppearanceRowMapper mapper, Guid value) { mapper.Object.Wearables[1].ItemID = new UUID(value.ToString()); });
88
89 rowMapperSchema.AddMapping<Guid>("WearableAsset1",
90 delegate(AppearanceRowMapper mapper) { return mapper.Object.Wearables[1].AssetID.Guid; },
91 delegate(AppearanceRowMapper mapper, Guid value)
92 { mapper.Object.Wearables[1].AssetID = new UUID(value.ToString()); });
93
94 rowMapperSchema.AddMapping<Guid>("WearableItem2",
95 delegate(AppearanceRowMapper mapper) { return mapper.Object.Wearables[2].ItemID.Guid; },
96 delegate(AppearanceRowMapper mapper, Guid value) { mapper.Object.Wearables[2].ItemID = new UUID(value.ToString()); });
97
98 rowMapperSchema.AddMapping<Guid>("WearableAsset2",
99 delegate(AppearanceRowMapper mapper) { return mapper.Object.Wearables[2].AssetID.Guid; },
100 delegate(AppearanceRowMapper mapper, Guid value)
101 { mapper.Object.Wearables[2].AssetID = new UUID(value.ToString()); });
102
103 rowMapperSchema.AddMapping<Guid>("WearableItem3",
104 delegate(AppearanceRowMapper mapper) { return mapper.Object.Wearables[3].ItemID.Guid; },
105 delegate(AppearanceRowMapper mapper, Guid value) { mapper.Object.Wearables[3].ItemID = new UUID(value.ToString()); });
106
107 rowMapperSchema.AddMapping<Guid>("WearableAsset3",
108 delegate(AppearanceRowMapper mapper) { return mapper.Object.Wearables[3].AssetID.Guid; },
109 delegate(AppearanceRowMapper mapper, Guid value)
110 { mapper.Object.Wearables[3].AssetID = new UUID(value.ToString()); });
111
112 rowMapperSchema.AddMapping<Guid>("WearableItem4",
113 delegate(AppearanceRowMapper mapper) { return mapper.Object.Wearables[4].ItemID.Guid; },
114 delegate(AppearanceRowMapper mapper, Guid value) { mapper.Object.Wearables[4].ItemID = new UUID(value.ToString()); });
115
116 rowMapperSchema.AddMapping<Guid>("WearableAsset4",
117 delegate(AppearanceRowMapper mapper) { return mapper.Object.Wearables[4].AssetID.Guid; },
118 delegate(AppearanceRowMapper mapper, Guid value)
119 { mapper.Object.Wearables[4].AssetID = new UUID(value.ToString()); });
120
121 rowMapperSchema.AddMapping<Guid>("WearableItem5",
122 delegate(AppearanceRowMapper mapper) { return mapper.Object.Wearables[5].ItemID.Guid; },
123 delegate(AppearanceRowMapper mapper, Guid value) { mapper.Object.Wearables[5].ItemID = new UUID(value.ToString()); });
124
125 rowMapperSchema.AddMapping<Guid>("WearableAsset5",
126 delegate(AppearanceRowMapper mapper) { return mapper.Object.Wearables[5].AssetID.Guid; },
127 delegate(AppearanceRowMapper mapper, Guid value)
128 { mapper.Object.Wearables[5].AssetID = new UUID(value.ToString()); });
129
130 rowMapperSchema.AddMapping<Guid>("WearableItem6",
131 delegate(AppearanceRowMapper mapper) { return mapper.Object.Wearables[6].ItemID.Guid; },
132 delegate(AppearanceRowMapper mapper, Guid value) { mapper.Object.Wearables[6].ItemID = new UUID(value.ToString()); });
133
134 rowMapperSchema.AddMapping<Guid>("WearableAsset6",
135 delegate(AppearanceRowMapper mapper) { return mapper.Object.Wearables[6].AssetID.Guid; },
136 delegate(AppearanceRowMapper mapper, Guid value)
137 { mapper.Object.Wearables[6].AssetID = new UUID(value.ToString()); });
138
139 rowMapperSchema.AddMapping<Guid>("WearableItem7",
140 delegate(AppearanceRowMapper mapper) { return mapper.Object.Wearables[7].ItemID.Guid; },
141 delegate(AppearanceRowMapper mapper, Guid value) { mapper.Object.Wearables[7].ItemID = new UUID(value.ToString()); });
142
143 rowMapperSchema.AddMapping<Guid>("WearableAsset7",
144 delegate(AppearanceRowMapper mapper) { return mapper.Object.Wearables[7].AssetID.Guid; },
145 delegate(AppearanceRowMapper mapper, Guid value)
146 { mapper.Object.Wearables[7].AssetID = new UUID(value.ToString()); });
147
148 rowMapperSchema.AddMapping<Guid>("WearableItem8",
149 delegate(AppearanceRowMapper mapper) { return mapper.Object.Wearables[8].ItemID.Guid; },
150 delegate(AppearanceRowMapper mapper, Guid value) { mapper.Object.Wearables[8].ItemID = new UUID(value.ToString()); });
151
152 rowMapperSchema.AddMapping<Guid>("WearableAsset8",
153 delegate(AppearanceRowMapper mapper) { return mapper.Object.Wearables[8].AssetID.Guid; },
154 delegate(AppearanceRowMapper mapper, Guid value)
155 { mapper.Object.Wearables[8].AssetID = new UUID(value.ToString()); });
156
157 rowMapperSchema.AddMapping<Guid>("WearableItem9",
158 delegate(AppearanceRowMapper mapper) { return mapper.Object.Wearables[9].ItemID.Guid; },
159 delegate(AppearanceRowMapper mapper, Guid value) { mapper.Object.Wearables[9].ItemID = new UUID(value.ToString()); });
160
161 rowMapperSchema.AddMapping<Guid>("WearableAsset9",
162 delegate(AppearanceRowMapper mapper) { return mapper.Object.Wearables[9].AssetID.Guid; },
163 delegate(AppearanceRowMapper mapper, Guid value)
164 { mapper.Object.Wearables[9].AssetID = new UUID(value.ToString()); });
165
166 rowMapperSchema.AddMapping<Guid>("WearableItem10",
167 delegate(AppearanceRowMapper mapper) { return mapper.Object.Wearables[10].ItemID.Guid; },
168 delegate(AppearanceRowMapper mapper, Guid value) { mapper.Object.Wearables[10].ItemID = new UUID(value.ToString()); });
169
170 rowMapperSchema.AddMapping<Guid>("WearableAsset10",
171 delegate(AppearanceRowMapper mapper) { return mapper.Object.Wearables[10].AssetID.Guid; },
172 delegate(AppearanceRowMapper mapper, Guid value)
173 { mapper.Object.Wearables[10].AssetID = new UUID(value.ToString()); });
174
175 rowMapperSchema.AddMapping<Guid>("WearableItem11",
176 delegate(AppearanceRowMapper mapper) { return mapper.Object.Wearables[11].ItemID.Guid; },
177 delegate(AppearanceRowMapper mapper, Guid value) { mapper.Object.Wearables[11].ItemID = new UUID(value.ToString()); });
178
179 rowMapperSchema.AddMapping<Guid>("WearableAsset11",
180 delegate(AppearanceRowMapper mapper) { return mapper.Object.Wearables[11].AssetID.Guid; },
181 delegate(AppearanceRowMapper mapper, Guid value)
182 { mapper.Object.Wearables[11].AssetID = new UUID(value.ToString()); });
183
184 rowMapperSchema.AddMapping<Guid>("WearableItem12",
185 delegate(AppearanceRowMapper mapper) { return mapper.Object.Wearables[12].ItemID.Guid; },
186 delegate(AppearanceRowMapper mapper, Guid value) { mapper.Object.Wearables[12].ItemID = new UUID(value.ToString()); });
187
188 rowMapperSchema.AddMapping<Guid>("WearableAsset12",
189 delegate(AppearanceRowMapper mapper) { return mapper.Object.Wearables[12].AssetID.Guid; },
190 delegate(AppearanceRowMapper mapper, Guid value)
191 { mapper.Object.Wearables[12].AssetID = new UUID(value.ToString()); });
192
193 }
194
195 /// <summary>
196 ///
197 /// </summary>
198 /// <param name="userID"></param>
199 /// <param name="appearance"></param>
200 /// <returns></returns>
201 public bool Add(Guid userID, AvatarAppearance appearance)
202 {
203 AppearanceRowMapper mapper = CreateRowMapper(appearance);
204 return Add(mapper);
205 }
206
207 /// <summary>
208 ///
209 /// </summary>
210 /// <param name="userID"></param>
211 /// <param name="appearance"></param>
212 /// <returns></returns>
213 public bool Update(Guid userID, AvatarAppearance appearance)
214 {
215 AppearanceRowMapper mapper = CreateRowMapper(appearance);
216 return Update(appearance.Owner.Guid, mapper);
217 }
218
219 /// <summary>
220 ///
221 /// </summary>
222 /// <param name="appearance"></param>
223 /// <returns></returns>
224 protected AppearanceRowMapper CreateRowMapper(AvatarAppearance appearance)
225 {
226 return new AppearanceRowMapper(m_schema, appearance);
227 }
228
229 /// <summary>
230 ///
231 /// </summary>
232 /// <returns></returns>
233 protected AppearanceRowMapper CreateRowMapper()
234 {
235 return CreateRowMapper(new AvatarAppearance());
236 }
237
238 /// <summary>
239 ///
240 /// </summary>
241 /// <param name="reader"></param>
242 /// <param name="appearance"></param>
243 /// <returns></returns>
244 protected AppearanceRowMapper FromReader(BaseDataReader reader, AvatarAppearance appearance)
245 {
246 AppearanceRowMapper mapper = CreateRowMapper(appearance);
247 mapper.FiPrimitive(reader);
248 return mapper;
249 }
250
251 /// <summary>
252 ///
253 /// </summary>
254 /// <param name="reader"></param>
255 /// <returns></returns>
256 public override AppearanceRowMapper FromReader(BaseDataReader reader)
257 {
258 AppearanceRowMapper mapper = CreateRowMapper();
259 mapper.FiPrimitive(reader);
260 return mapper;
261 }
262
263 /// <summary>
264 ///
265 /// </summary>
266 /// <param name="presenceID"></param>
267 /// <param name="val"></param>
268 /// <returns></returns>
269 public bool TryGetValue(Guid presenceID, out AvatarAppearance val)
270 {
271 AppearanceRowMapper mapper;
272 if (TryGetValue(presenceID, out mapper))
273 {
274 val = mapper.Object;
275 return true;
276 }
277 else
278 {
279 val = null;
280 return false;
281 }
282 }
283 }
284}