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