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