aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Data/Base/AppearanceTableMapper.cs
diff options
context:
space:
mode:
authorSean Dague2008-05-16 14:05:12 +0000
committerSean Dague2008-05-16 14:05:12 +0000
commite6d4c8f0c9b971b9aacc01d38ac69e6f434c51f5 (patch)
tree2db5c64b837a3f63e8fd0cbeb033f7cfdc8361fc /OpenSim/Data/Base/AppearanceTableMapper.cs
parentMinor cleanup. (diff)
downloadopensim-SC-e6d4c8f0c9b971b9aacc01d38ac69e6f434c51f5.zip
opensim-SC-e6d4c8f0c9b971b9aacc01d38ac69e6f434c51f5.tar.gz
opensim-SC-e6d4c8f0c9b971b9aacc01d38ac69e6f434c51f5.tar.bz2
opensim-SC-e6d4c8f0c9b971b9aacc01d38ac69e6f434c51f5.tar.xz
move AppearanceTableMapper to OpenSim.Data.Base. The mapper
stuff should probably be collapsed soon, as it takes up 4 assemblies now.
Diffstat (limited to 'OpenSim/Data/Base/AppearanceTableMapper.cs')
-rw-r--r--OpenSim/Data/Base/AppearanceTableMapper.cs240
1 files changed, 240 insertions, 0 deletions
diff --git a/OpenSim/Data/Base/AppearanceTableMapper.cs b/OpenSim/Data/Base/AppearanceTableMapper.cs
new file mode 100644
index 0000000..60acfe0
--- /dev/null
+++ b/OpenSim/Data/Base/AppearanceTableMapper.cs
@@ -0,0 +1,240 @@
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 libsecondlife;
30using OpenSim.Data.Base;
31using OpenSim.Framework;
32
33namespace OpenSim.Data.Base
34{
35 public class AppearanceRowMapper : BaseRowMapper<AvatarAppearance>
36 {
37 public AppearanceRowMapper(BaseSchema schema, AvatarAppearance obj)
38 : base(schema, obj)
39 {
40 }
41 }
42
43 public class AppearanceTableMapper : BaseTableMapper<AppearanceRowMapper, Guid>
44 {
45 public AppearanceTableMapper(BaseDatabaseConnector database, string tableName)
46 : base(database, tableName)
47 {
48 BaseSchema<AppearanceRowMapper> rowMapperSchema = new BaseSchema<AppearanceRowMapper>(this);
49 m_schema = rowMapperSchema;
50
51 m_keyFieldMapper = rowMapperSchema.AddMapping<Guid>("UUID",
52 delegate(AppearanceRowMapper mapper) { return mapper.Object.Owner.UUID; },
53 delegate(AppearanceRowMapper mapper, Guid value) { mapper.Object.Owner = new LLUUID(value.ToString()); });
54
55 rowMapperSchema.AddMapping<uint>("Serial",
56 delegate(AppearanceRowMapper mapper) { return (uint)mapper.Object.Serial; },
57 delegate(AppearanceRowMapper mapper, uint value) { mapper.Object.Serial = (int)value; });
58
59 rowMapperSchema.AddMapping<Guid>("WearableItem0",
60 delegate(AppearanceRowMapper mapper) { return mapper.Object.Wearables[0].ItemID.UUID; },
61 delegate(AppearanceRowMapper mapper, Guid value)
62 {
63 if (mapper.Object.Wearables == null)
64 {
65 mapper.Object.Wearables = new AvatarWearable[13];
66 for (int i = 0; i < 13; i++)
67 {
68 mapper.Object.Wearables[i] = new AvatarWearable();
69 }
70 }
71 mapper.Object.Wearables[0].ItemID = new LLUUID(value.ToString());
72 });
73
74 rowMapperSchema.AddMapping<Guid>("WearableAsset0",
75 delegate(AppearanceRowMapper mapper) { return mapper.Object.Wearables[0].AssetID.UUID; },
76 delegate(AppearanceRowMapper mapper, Guid value)
77 { mapper.Object.Wearables[0].AssetID = new LLUUID(value.ToString()); });
78
79 rowMapperSchema.AddMapping<Guid>("WearableItem1",
80 delegate(AppearanceRowMapper mapper) { return mapper.Object.Wearables[1].ItemID.UUID; },
81 delegate(AppearanceRowMapper mapper, Guid value) { mapper.Object.Wearables[1].ItemID = new LLUUID(value.ToString()); });
82
83 rowMapperSchema.AddMapping<Guid>("WearableAsset1",
84 delegate(AppearanceRowMapper mapper) { return mapper.Object.Wearables[1].AssetID.UUID; },
85 delegate(AppearanceRowMapper mapper, Guid value)
86 { mapper.Object.Wearables[1].AssetID = new LLUUID(value.ToString()); });
87
88 rowMapperSchema.AddMapping<Guid>("WearableItem2",
89 delegate(AppearanceRowMapper mapper) { return mapper.Object.Wearables[2].ItemID.UUID; },
90 delegate(AppearanceRowMapper mapper, Guid value) { mapper.Object.Wearables[2].ItemID = new LLUUID(value.ToString()); });
91
92 rowMapperSchema.AddMapping<Guid>("WearableAsset2",
93 delegate(AppearanceRowMapper mapper) { return mapper.Object.Wearables[2].AssetID.UUID; },
94 delegate(AppearanceRowMapper mapper, Guid value)
95 { mapper.Object.Wearables[2].AssetID = new LLUUID(value.ToString()); });
96
97 rowMapperSchema.AddMapping<Guid>("WearableItem3",
98 delegate(AppearanceRowMapper mapper) { return mapper.Object.Wearables[3].ItemID.UUID; },
99 delegate(AppearanceRowMapper mapper, Guid value) { mapper.Object.Wearables[3].ItemID = new LLUUID(value.ToString()); });
100
101 rowMapperSchema.AddMapping<Guid>("WearableAsset3",
102 delegate(AppearanceRowMapper mapper) { return mapper.Object.Wearables[3].AssetID.UUID; },
103 delegate(AppearanceRowMapper mapper, Guid value)
104 { mapper.Object.Wearables[3].AssetID = new LLUUID(value.ToString()); });
105
106 rowMapperSchema.AddMapping<Guid>("WearableItem4",
107 delegate(AppearanceRowMapper mapper) { return mapper.Object.Wearables[4].ItemID.UUID; },
108 delegate(AppearanceRowMapper mapper, Guid value) { mapper.Object.Wearables[4].ItemID = new LLUUID(value.ToString()); });
109
110 rowMapperSchema.AddMapping<Guid>("WearableAsset4",
111 delegate(AppearanceRowMapper mapper) { return mapper.Object.Wearables[4].AssetID.UUID; },
112 delegate(AppearanceRowMapper mapper, Guid value)
113 { mapper.Object.Wearables[4].AssetID = new LLUUID(value.ToString()); });
114
115 rowMapperSchema.AddMapping<Guid>("WearableItem5",
116 delegate(AppearanceRowMapper mapper) { return mapper.Object.Wearables[5].ItemID.UUID; },
117 delegate(AppearanceRowMapper mapper, Guid value) { mapper.Object.Wearables[5].ItemID = new LLUUID(value.ToString()); });
118
119 rowMapperSchema.AddMapping<Guid>("WearableAsset5",
120 delegate(AppearanceRowMapper mapper) { return mapper.Object.Wearables[5].AssetID.UUID; },
121 delegate(AppearanceRowMapper mapper, Guid value)
122 { mapper.Object.Wearables[5].AssetID = new LLUUID(value.ToString()); });
123
124 rowMapperSchema.AddMapping<Guid>("WearableItem6",
125 delegate(AppearanceRowMapper mapper) { return mapper.Object.Wearables[6].ItemID.UUID; },
126 delegate(AppearanceRowMapper mapper, Guid value) { mapper.Object.Wearables[6].ItemID = new LLUUID(value.ToString()); });
127
128 rowMapperSchema.AddMapping<Guid>("WearableAsset6",
129 delegate(AppearanceRowMapper mapper) { return mapper.Object.Wearables[6].AssetID.UUID; },
130 delegate(AppearanceRowMapper mapper, Guid value)
131 { mapper.Object.Wearables[6].AssetID = new LLUUID(value.ToString()); });
132
133 rowMapperSchema.AddMapping<Guid>("WearableItem7",
134 delegate(AppearanceRowMapper mapper) { return mapper.Object.Wearables[7].ItemID.UUID; },
135 delegate(AppearanceRowMapper mapper, Guid value) { mapper.Object.Wearables[7].ItemID = new LLUUID(value.ToString()); });
136
137 rowMapperSchema.AddMapping<Guid>("WearableAsset7",
138 delegate(AppearanceRowMapper mapper) { return mapper.Object.Wearables[7].AssetID.UUID; },
139 delegate(AppearanceRowMapper mapper, Guid value)
140 { mapper.Object.Wearables[7].AssetID = new LLUUID(value.ToString()); });
141
142 rowMapperSchema.AddMapping<Guid>("WearableItem8",
143 delegate(AppearanceRowMapper mapper) { return mapper.Object.Wearables[8].ItemID.UUID; },
144 delegate(AppearanceRowMapper mapper, Guid value) { mapper.Object.Wearables[8].ItemID = new LLUUID(value.ToString()); });
145
146 rowMapperSchema.AddMapping<Guid>("WearableAsset8",
147 delegate(AppearanceRowMapper mapper) { return mapper.Object.Wearables[8].AssetID.UUID; },
148 delegate(AppearanceRowMapper mapper, Guid value)
149 { mapper.Object.Wearables[8].AssetID = new LLUUID(value.ToString()); });
150
151 rowMapperSchema.AddMapping<Guid>("WearableItem9",
152 delegate(AppearanceRowMapper mapper) { return mapper.Object.Wearables[9].ItemID.UUID; },
153 delegate(AppearanceRowMapper mapper, Guid value) { mapper.Object.Wearables[9].ItemID = new LLUUID(value.ToString()); });
154
155 rowMapperSchema.AddMapping<Guid>("WearableAsset9",
156 delegate(AppearanceRowMapper mapper) { return mapper.Object.Wearables[9].AssetID.UUID; },
157 delegate(AppearanceRowMapper mapper, Guid value)
158 { mapper.Object.Wearables[9].AssetID = new LLUUID(value.ToString()); });
159
160 rowMapperSchema.AddMapping<Guid>("WearableItem10",
161 delegate(AppearanceRowMapper mapper) { return mapper.Object.Wearables[10].ItemID.UUID; },
162 delegate(AppearanceRowMapper mapper, Guid value) { mapper.Object.Wearables[10].ItemID = new LLUUID(value.ToString()); });
163
164 rowMapperSchema.AddMapping<Guid>("WearableAsset10",
165 delegate(AppearanceRowMapper mapper) { return mapper.Object.Wearables[10].AssetID.UUID; },
166 delegate(AppearanceRowMapper mapper, Guid value)
167 { mapper.Object.Wearables[10].AssetID = new LLUUID(value.ToString()); });
168
169 rowMapperSchema.AddMapping<Guid>("WearableItem11",
170 delegate(AppearanceRowMapper mapper) { return mapper.Object.Wearables[11].ItemID.UUID; },
171 delegate(AppearanceRowMapper mapper, Guid value) { mapper.Object.Wearables[11].ItemID = new LLUUID(value.ToString()); });
172
173 rowMapperSchema.AddMapping<Guid>("WearableAsset11",
174 delegate(AppearanceRowMapper mapper) { return mapper.Object.Wearables[11].AssetID.UUID; },
175 delegate(AppearanceRowMapper mapper, Guid value)
176 { mapper.Object.Wearables[11].AssetID = new LLUUID(value.ToString()); });
177
178 rowMapperSchema.AddMapping<Guid>("WearableItem12",
179 delegate(AppearanceRowMapper mapper) { return mapper.Object.Wearables[12].ItemID.UUID; },
180 delegate(AppearanceRowMapper mapper, Guid value) { mapper.Object.Wearables[12].ItemID = new LLUUID(value.ToString()); });
181
182 rowMapperSchema.AddMapping<Guid>("WearableAsset12",
183 delegate(AppearanceRowMapper mapper) { return mapper.Object.Wearables[12].AssetID.UUID; },
184 delegate(AppearanceRowMapper mapper, Guid value)
185 { mapper.Object.Wearables[12].AssetID = new LLUUID(value.ToString()); });
186
187 }
188
189 public bool Add(Guid userID, AvatarAppearance appearance)
190 {
191 AppearanceRowMapper mapper = CreateRowMapper(appearance);
192 return Add(mapper);
193 }
194
195 public bool Update(Guid userID, AvatarAppearance appearance)
196 {
197 AppearanceRowMapper mapper = CreateRowMapper(appearance);
198 return Update(appearance.Owner.UUID, mapper);
199 }
200
201 protected AppearanceRowMapper CreateRowMapper(AvatarAppearance appearance)
202 {
203 return new AppearanceRowMapper(m_schema, appearance);
204 }
205
206 protected AppearanceRowMapper CreateRowMapper()
207 {
208 return CreateRowMapper(new AvatarAppearance());
209 }
210
211 protected AppearanceRowMapper FromReader(BaseDataReader reader, AvatarAppearance appearance)
212 {
213 AppearanceRowMapper mapper = CreateRowMapper(appearance);
214 mapper.FillObject(reader);
215 return mapper;
216 }
217
218 public override AppearanceRowMapper FromReader(BaseDataReader reader)
219 {
220 AppearanceRowMapper mapper = CreateRowMapper();
221 mapper.FillObject(reader);
222 return mapper;
223 }
224
225 public bool TryGetValue(Guid presenceID, out AvatarAppearance val)
226 {
227 AppearanceRowMapper mapper;
228 if (TryGetValue(presenceID, out mapper))
229 {
230 val = mapper.Object;
231 return true;
232 }
233 else
234 {
235 val = null;
236 return false;
237 }
238 }
239 }
240}