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