aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Framework/Data/PrimitiveBaseShapeTableMapper.cs
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--OpenSim/Framework/Data/PrimitiveBaseShapeTableMapper.cs143
1 files changed, 143 insertions, 0 deletions
diff --git a/OpenSim/Framework/Data/PrimitiveBaseShapeTableMapper.cs b/OpenSim/Framework/Data/PrimitiveBaseShapeTableMapper.cs
new file mode 100644
index 0000000..8026373
--- /dev/null
+++ b/OpenSim/Framework/Data/PrimitiveBaseShapeTableMapper.cs
@@ -0,0 +1,143 @@
1using System;
2using OpenSim.Framework;
3using TribalMedia.Framework.Data;
4using libsecondlife;
5
6namespace OpenSim.Framework.Data
7{
8 public class PrimitiveBaseShapeRowMapper : RowMapper<PrimitiveBaseShape>
9 {
10 public Guid SceneObjectPartId;
11
12 public PrimitiveBaseShapeRowMapper(Schema schema, PrimitiveBaseShape obj) : base(schema, obj)
13 {
14 }
15 }
16
17 public class PrimitiveBaseShapeTableMapper : ObjectTableMapper<PrimitiveBaseShapeRowMapper, Guid>
18 {
19 public PrimitiveBaseShapeTableMapper(DatabaseMapper connection, string tableName)
20 : base(connection, tableName)
21 {
22 RowMapperSchema<PrimitiveBaseShapeRowMapper> rowMapperSchema = new RowMapperSchema<PrimitiveBaseShapeRowMapper>(this);
23 m_schema = rowMapperSchema;
24
25 m_keyFieldMapper = rowMapperSchema.AddMapping<Guid>("SceneObjectPartId",
26 delegate(PrimitiveBaseShapeRowMapper shape) { return shape.SceneObjectPartId; },
27 delegate(PrimitiveBaseShapeRowMapper shape, Guid value) { shape.SceneObjectPartId = value; });
28
29 rowMapperSchema.AddMapping<byte>("PCode",
30 delegate(PrimitiveBaseShapeRowMapper shape) { return shape.Object.PCode; },
31 delegate(PrimitiveBaseShapeRowMapper shape, byte value) { shape.Object.PCode = value; });
32
33 rowMapperSchema.AddMapping<ushort>("PathBegin",
34 delegate(PrimitiveBaseShapeRowMapper shape) { return shape.Object.PathBegin; },
35 delegate(PrimitiveBaseShapeRowMapper shape, ushort value) { shape.Object.PathBegin = value; });
36
37 rowMapperSchema.AddMapping<ushort>("PathEnd",
38 delegate(PrimitiveBaseShapeRowMapper shape) { return shape.Object.PathEnd; },
39 delegate(PrimitiveBaseShapeRowMapper shape, ushort value) { shape.Object.PathEnd = value; });
40
41 rowMapperSchema.AddMapping<byte>("PathScaleX",
42 delegate(PrimitiveBaseShapeRowMapper shape) { return shape.Object.PathScaleX; },
43 delegate(PrimitiveBaseShapeRowMapper shape, byte value) { shape.Object.PathScaleX = value; });
44
45 rowMapperSchema.AddMapping<byte>("PathScaleY",
46 delegate(PrimitiveBaseShapeRowMapper shape) { return shape.Object.PathScaleY; },
47 delegate(PrimitiveBaseShapeRowMapper shape, byte value) { shape.Object.PathScaleY = value; });
48
49 rowMapperSchema.AddMapping<byte>("PathShearX",
50 delegate(PrimitiveBaseShapeRowMapper shape) { return shape.Object.PathShearX; },
51 delegate(PrimitiveBaseShapeRowMapper shape, byte value) { shape.Object.PathShearX = value; });
52
53 rowMapperSchema.AddMapping<byte>("PathShearY",
54 delegate(PrimitiveBaseShapeRowMapper shape) { return shape.Object.PathShearY; },
55 delegate(PrimitiveBaseShapeRowMapper shape, byte value) { shape.Object.PathShearY = value; });
56
57 rowMapperSchema.AddMapping<ushort>("ProfileBegin",
58 delegate(PrimitiveBaseShapeRowMapper shape) { return shape.Object.ProfileBegin; },
59 delegate(PrimitiveBaseShapeRowMapper shape, ushort value) { shape.Object.ProfileBegin = value; });
60
61 rowMapperSchema.AddMapping<ushort>("ProfileEnd",
62 delegate(PrimitiveBaseShapeRowMapper shape) { return shape.Object.ProfileEnd; },
63 delegate(PrimitiveBaseShapeRowMapper shape, ushort value) { shape.Object.ProfileEnd = value; });
64
65 rowMapperSchema.AddMapping<LLVector3>("Scale",
66 delegate(PrimitiveBaseShapeRowMapper shape) { return shape.Object.Scale; },
67 delegate(PrimitiveBaseShapeRowMapper shape, LLVector3 value) { shape.Object.Scale = value; });
68
69 rowMapperSchema.AddMapping<sbyte>("PathTaperX",
70 delegate(PrimitiveBaseShapeRowMapper shape) { return shape.Object.PathTaperX; },
71 delegate(PrimitiveBaseShapeRowMapper shape, sbyte value) { shape.Object.PathTaperX = value; });
72
73 rowMapperSchema.AddMapping<sbyte>("PathTaperY",
74 delegate(PrimitiveBaseShapeRowMapper shape) { return shape.Object.PathTaperY; },
75 delegate(PrimitiveBaseShapeRowMapper shape, sbyte value) { shape.Object.PathTaperY = value; });
76
77 rowMapperSchema.AddMapping<sbyte>("PathTwist",
78 delegate(PrimitiveBaseShapeRowMapper shape) { return shape.Object.PathTwist; },
79 delegate(PrimitiveBaseShapeRowMapper shape, sbyte value) { shape.Object.PathTwist = value; });
80
81 rowMapperSchema.AddMapping<sbyte>("PathRadiusOffset",
82 delegate(PrimitiveBaseShapeRowMapper shape) { return shape.Object.PathRadiusOffset; },
83 delegate(PrimitiveBaseShapeRowMapper shape, sbyte value) { shape.Object.PathRadiusOffset = value; });
84
85 rowMapperSchema.AddMapping<byte>("PathRevolutions",
86 delegate(PrimitiveBaseShapeRowMapper shape) { return shape.Object.PathRevolutions; },
87 delegate(PrimitiveBaseShapeRowMapper shape, byte value) { shape.Object.PathRevolutions = value; });
88
89 rowMapperSchema.AddMapping<sbyte>("PathTwistBegin",
90 delegate(PrimitiveBaseShapeRowMapper shape) { return shape.Object.PathTwistBegin; },
91 delegate(PrimitiveBaseShapeRowMapper shape, sbyte value) { shape.Object.PathTwistBegin = value; });
92
93 rowMapperSchema.AddMapping<byte>("PathCurve",
94 delegate(PrimitiveBaseShapeRowMapper shape) { return shape.Object.PathCurve; },
95 delegate(PrimitiveBaseShapeRowMapper shape, byte value) { shape.Object.PathCurve = value; });
96
97 rowMapperSchema.AddMapping<byte>("ProfileCurve",
98 delegate(PrimitiveBaseShapeRowMapper shape) { return shape.Object.ProfileCurve; },
99 delegate(PrimitiveBaseShapeRowMapper shape, byte value) { shape.Object.ProfileCurve = value; });
100
101 rowMapperSchema.AddMapping<ushort>("ProfileHollow",
102 delegate(PrimitiveBaseShapeRowMapper shape) { return shape.Object.ProfileHollow; },
103 delegate(PrimitiveBaseShapeRowMapper shape, ushort value) { shape.Object.ProfileHollow = value; });
104
105 rowMapperSchema.AddMapping<byte[]>("TextureEntry",
106 delegate(PrimitiveBaseShapeRowMapper shape) { return shape.Object.TextureEntry; },
107 delegate(PrimitiveBaseShapeRowMapper shape, byte[] value) { shape.Object.TextureEntry = value; });
108
109 rowMapperSchema.AddMapping<byte[]>("ExtraParams",
110 delegate(PrimitiveBaseShapeRowMapper shape) { return shape.Object.ExtraParams; },
111 delegate(PrimitiveBaseShapeRowMapper shape, byte[] value) { shape.Object.ExtraParams = value; });
112 }
113
114 public override PrimitiveBaseShapeRowMapper FromReader(DataReader reader)
115 {
116 PrimitiveBaseShape shape = new PrimitiveBaseShape();
117
118 PrimitiveBaseShapeRowMapper mapper = new PrimitiveBaseShapeRowMapper(m_schema, shape);
119 mapper.FillObject( reader );
120
121 return mapper;
122 }
123
124 public bool Update(Guid sceneObjectPartId, PrimitiveBaseShape primitiveBaseShape)
125 {
126 PrimitiveBaseShapeRowMapper mapper = CreateRowMapper(sceneObjectPartId, primitiveBaseShape);
127 return Update(sceneObjectPartId, mapper);
128 }
129
130 public bool Add(Guid sceneObjectPartId, PrimitiveBaseShape primitiveBaseShape)
131 {
132 PrimitiveBaseShapeRowMapper mapper = CreateRowMapper(sceneObjectPartId, primitiveBaseShape);
133 return Add(mapper);
134 }
135
136 private PrimitiveBaseShapeRowMapper CreateRowMapper(Guid sceneObjectPartId, PrimitiveBaseShape primitiveBaseShape)
137 {
138 PrimitiveBaseShapeRowMapper mapper = new PrimitiveBaseShapeRowMapper( m_schema, primitiveBaseShape );
139 mapper.SceneObjectPartId = sceneObjectPartId;
140 return mapper;
141 }
142 }
143} \ No newline at end of file