Set svn:eol-style.

ThreadPoolClientBranch
Jeff Ames 2008-01-14 22:37:45 +00:00
parent 6d751411b7
commit 84c3a317c1
5 changed files with 301 additions and 301 deletions

View File

@ -1,24 +1,24 @@
using System.Data.Common; using System.Data.Common;
using MySql.Data.MySqlClient; using MySql.Data.MySqlClient;
namespace OpenSim.Framework.Data.MySQL namespace OpenSim.Framework.Data.MySQL
{ {
public class MySQLDatabaseMapper : OpenSimDatabaseMapper public class MySQLDatabaseMapper : OpenSimDatabaseMapper
{ {
public MySQLDatabaseMapper(string connectionString) public MySQLDatabaseMapper(string connectionString)
: base(connectionString) : base(connectionString)
{ {
} }
public override DbConnection GetNewConnection() public override DbConnection GetNewConnection()
{ {
MySqlConnection connection = new MySqlConnection(m_connectionString); MySqlConnection connection = new MySqlConnection(m_connectionString);
return connection; return connection;
} }
public override string CreateParamName(string fieldName) public override string CreateParamName(string fieldName)
{ {
return "?" + fieldName; return "?" + fieldName;
} }
} }
} }

View File

@ -1,39 +1,39 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Data; using System.Data;
using System.Text; using System.Text;
using libsecondlife; using libsecondlife;
using TribalMedia.Framework.Data; using TribalMedia.Framework.Data;
namespace OpenSim.Framework.Data namespace OpenSim.Framework.Data
{ {
public class OpenSimDataReader : DataReader public class OpenSimDataReader : DataReader
{ {
public OpenSimDataReader(IDataReader source) : base(source) public OpenSimDataReader(IDataReader source) : base(source)
{ {
} }
public LLVector3 GetVector(string s) public LLVector3 GetVector(string s)
{ {
float x = GetFloat(s + "X"); float x = GetFloat(s + "X");
float y = GetFloat(s + "Y"); float y = GetFloat(s + "Y");
float z = GetFloat(s + "Z"); float z = GetFloat(s + "Z");
LLVector3 vector = new LLVector3(x, y, z); LLVector3 vector = new LLVector3(x, y, z);
return vector; return vector;
} }
public LLQuaternion GetQuaternion(string s) public LLQuaternion GetQuaternion(string s)
{ {
float x = GetFloat(s + "X"); float x = GetFloat(s + "X");
float y = GetFloat(s + "Y"); float y = GetFloat(s + "Y");
float z = GetFloat(s + "Z"); float z = GetFloat(s + "Z");
float w = GetFloat(s + "W"); float w = GetFloat(s + "W");
LLQuaternion quaternion = new LLQuaternion(x, y, z, w); LLQuaternion quaternion = new LLQuaternion(x, y, z, w);
return quaternion; return quaternion;
} }
} }
} }

View File

@ -1,23 +1,23 @@
using System.Data.Common; using System.Data.Common;
using libsecondlife; using libsecondlife;
using TribalMedia.Framework.Data; using TribalMedia.Framework.Data;
namespace OpenSim.Framework.Data namespace OpenSim.Framework.Data
{ {
public abstract class OpenSimDatabaseMapper : DatabaseMapper public abstract class OpenSimDatabaseMapper : DatabaseMapper
{ {
public OpenSimDatabaseMapper(string connectionString) : base(connectionString) public OpenSimDatabaseMapper(string connectionString) : base(connectionString)
{ {
} }
public override object ConvertToDbType(object value) public override object ConvertToDbType(object value)
{ {
if (value is LLUUID) if (value is LLUUID)
{ {
return ((LLUUID) value).UUID.ToString(); return ((LLUUID) value).UUID.ToString();
} }
return base.ConvertToDbType(value); return base.ConvertToDbType(value);
} }
} }
} }

View File

@ -1,73 +1,73 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Text; using System.Text;
using libsecondlife; using libsecondlife;
using TribalMedia.Framework.Data; using TribalMedia.Framework.Data;
namespace OpenSim.Framework.Data namespace OpenSim.Framework.Data
{ {
public class OpenSimObjectFieldMapper<TObject, TField> : ObjectField<TObject, TField> public class OpenSimObjectFieldMapper<TObject, TField> : ObjectField<TObject, TField>
{ {
public OpenSimObjectFieldMapper(TableMapper tableMapper, string fieldName, public OpenSimObjectFieldMapper(TableMapper tableMapper, string fieldName,
ObjectGetAccessor<TObject, TField> rowMapperGetAccessor, ObjectGetAccessor<TObject, TField> rowMapperGetAccessor,
ObjectSetAccessor<TObject, TField> rowMapperSetAccessor) ObjectSetAccessor<TObject, TField> rowMapperSetAccessor)
: base(tableMapper, fieldName, rowMapperGetAccessor, rowMapperSetAccessor) : base(tableMapper, fieldName, rowMapperGetAccessor, rowMapperSetAccessor)
{ {
} }
public override void ExpandField<TObj>(TObj obj, System.Data.Common.DbCommand command, List<string> fieldNames) public override void ExpandField<TObj>(TObj obj, System.Data.Common.DbCommand command, List<string> fieldNames)
{ {
string fieldName = FieldName; string fieldName = FieldName;
object value = GetParamValue(obj); object value = GetParamValue(obj);
if (ValueType == typeof(LLVector3)) if (ValueType == typeof(LLVector3))
{ {
LLVector3 vector = (LLVector3)value; LLVector3 vector = (LLVector3)value;
RawAddParam(command, fieldNames, fieldName + "X", vector.X); RawAddParam(command, fieldNames, fieldName + "X", vector.X);
RawAddParam(command, fieldNames, fieldName + "Y", vector.Y); RawAddParam(command, fieldNames, fieldName + "Y", vector.Y);
RawAddParam(command, fieldNames, fieldName + "Z", vector.Z); RawAddParam(command, fieldNames, fieldName + "Z", vector.Z);
} }
else if (ValueType == typeof(LLQuaternion)) else if (ValueType == typeof(LLQuaternion))
{ {
LLQuaternion quaternion = (LLQuaternion)value; LLQuaternion quaternion = (LLQuaternion)value;
RawAddParam(command, fieldNames, fieldName + "X", quaternion.X); RawAddParam(command, fieldNames, fieldName + "X", quaternion.X);
RawAddParam(command, fieldNames, fieldName + "Y", quaternion.Y); RawAddParam(command, fieldNames, fieldName + "Y", quaternion.Y);
RawAddParam(command, fieldNames, fieldName + "Z", quaternion.Z); RawAddParam(command, fieldNames, fieldName + "Z", quaternion.Z);
RawAddParam(command, fieldNames, fieldName + "W", quaternion.W); RawAddParam(command, fieldNames, fieldName + "W", quaternion.W);
} }
else else
{ {
base.ExpandField<TObj>(obj, command, fieldNames); base.ExpandField<TObj>(obj, command, fieldNames);
} }
} }
protected override object GetValue(DataReader reader) protected override object GetValue(DataReader reader)
{ {
object value; object value;
OpenSimDataReader osreader = (OpenSimDataReader) reader; OpenSimDataReader osreader = (OpenSimDataReader) reader;
if (ValueType == typeof(LLVector3)) if (ValueType == typeof(LLVector3))
{ {
value = osreader.GetVector(FieldName); value = osreader.GetVector(FieldName);
} }
else if (ValueType == typeof(LLQuaternion)) else if (ValueType == typeof(LLQuaternion))
{ {
value = osreader.GetQuaternion(FieldName); value = osreader.GetQuaternion(FieldName);
} }
else if (ValueType == typeof(LLUUID)) else if (ValueType == typeof(LLUUID))
{ {
Guid guid = reader.GetGuid(FieldName); Guid guid = reader.GetGuid(FieldName);
value = new LLUUID(guid); value = new LLUUID(guid);
} }
else else
{ {
value = base.GetValue(reader); value = base.GetValue(reader);
} }
return value; return value;
} }
} }
} }

View File

@ -1,143 +1,143 @@
using System; using System;
using OpenSim.Framework; using OpenSim.Framework;
using TribalMedia.Framework.Data; using TribalMedia.Framework.Data;
using libsecondlife; using libsecondlife;
namespace OpenSim.Framework.Data namespace OpenSim.Framework.Data
{ {
public class PrimitiveBaseShapeRowMapper : RowMapper<PrimitiveBaseShape> public class PrimitiveBaseShapeRowMapper : RowMapper<PrimitiveBaseShape>
{ {
public Guid SceneObjectPartId; public Guid SceneObjectPartId;
public PrimitiveBaseShapeRowMapper(Schema schema, PrimitiveBaseShape obj) : base(schema, obj) public PrimitiveBaseShapeRowMapper(Schema schema, PrimitiveBaseShape obj) : base(schema, obj)
{ {
} }
} }
public class PrimitiveBaseShapeTableMapper : ObjectTableMapper<PrimitiveBaseShapeRowMapper, Guid> public class PrimitiveBaseShapeTableMapper : ObjectTableMapper<PrimitiveBaseShapeRowMapper, Guid>
{ {
public PrimitiveBaseShapeTableMapper(DatabaseMapper connection, string tableName) public PrimitiveBaseShapeTableMapper(DatabaseMapper connection, string tableName)
: base(connection, tableName) : base(connection, tableName)
{ {
RowMapperSchema<PrimitiveBaseShapeRowMapper> rowMapperSchema = new RowMapperSchema<PrimitiveBaseShapeRowMapper>(this); RowMapperSchema<PrimitiveBaseShapeRowMapper> rowMapperSchema = new RowMapperSchema<PrimitiveBaseShapeRowMapper>(this);
m_schema = rowMapperSchema; m_schema = rowMapperSchema;
m_keyFieldMapper = rowMapperSchema.AddMapping<Guid>("SceneObjectPartId", m_keyFieldMapper = rowMapperSchema.AddMapping<Guid>("SceneObjectPartId",
delegate(PrimitiveBaseShapeRowMapper shape) { return shape.SceneObjectPartId; }, delegate(PrimitiveBaseShapeRowMapper shape) { return shape.SceneObjectPartId; },
delegate(PrimitiveBaseShapeRowMapper shape, Guid value) { shape.SceneObjectPartId = value; }); delegate(PrimitiveBaseShapeRowMapper shape, Guid value) { shape.SceneObjectPartId = value; });
rowMapperSchema.AddMapping<byte>("PCode", rowMapperSchema.AddMapping<byte>("PCode",
delegate(PrimitiveBaseShapeRowMapper shape) { return shape.Object.PCode; }, delegate(PrimitiveBaseShapeRowMapper shape) { return shape.Object.PCode; },
delegate(PrimitiveBaseShapeRowMapper shape, byte value) { shape.Object.PCode = value; }); delegate(PrimitiveBaseShapeRowMapper shape, byte value) { shape.Object.PCode = value; });
rowMapperSchema.AddMapping<ushort>("PathBegin", rowMapperSchema.AddMapping<ushort>("PathBegin",
delegate(PrimitiveBaseShapeRowMapper shape) { return shape.Object.PathBegin; }, delegate(PrimitiveBaseShapeRowMapper shape) { return shape.Object.PathBegin; },
delegate(PrimitiveBaseShapeRowMapper shape, ushort value) { shape.Object.PathBegin = value; }); delegate(PrimitiveBaseShapeRowMapper shape, ushort value) { shape.Object.PathBegin = value; });
rowMapperSchema.AddMapping<ushort>("PathEnd", rowMapperSchema.AddMapping<ushort>("PathEnd",
delegate(PrimitiveBaseShapeRowMapper shape) { return shape.Object.PathEnd; }, delegate(PrimitiveBaseShapeRowMapper shape) { return shape.Object.PathEnd; },
delegate(PrimitiveBaseShapeRowMapper shape, ushort value) { shape.Object.PathEnd = value; }); delegate(PrimitiveBaseShapeRowMapper shape, ushort value) { shape.Object.PathEnd = value; });
rowMapperSchema.AddMapping<byte>("PathScaleX", rowMapperSchema.AddMapping<byte>("PathScaleX",
delegate(PrimitiveBaseShapeRowMapper shape) { return shape.Object.PathScaleX; }, delegate(PrimitiveBaseShapeRowMapper shape) { return shape.Object.PathScaleX; },
delegate(PrimitiveBaseShapeRowMapper shape, byte value) { shape.Object.PathScaleX = value; }); delegate(PrimitiveBaseShapeRowMapper shape, byte value) { shape.Object.PathScaleX = value; });
rowMapperSchema.AddMapping<byte>("PathScaleY", rowMapperSchema.AddMapping<byte>("PathScaleY",
delegate(PrimitiveBaseShapeRowMapper shape) { return shape.Object.PathScaleY; }, delegate(PrimitiveBaseShapeRowMapper shape) { return shape.Object.PathScaleY; },
delegate(PrimitiveBaseShapeRowMapper shape, byte value) { shape.Object.PathScaleY = value; }); delegate(PrimitiveBaseShapeRowMapper shape, byte value) { shape.Object.PathScaleY = value; });
rowMapperSchema.AddMapping<byte>("PathShearX", rowMapperSchema.AddMapping<byte>("PathShearX",
delegate(PrimitiveBaseShapeRowMapper shape) { return shape.Object.PathShearX; }, delegate(PrimitiveBaseShapeRowMapper shape) { return shape.Object.PathShearX; },
delegate(PrimitiveBaseShapeRowMapper shape, byte value) { shape.Object.PathShearX = value; }); delegate(PrimitiveBaseShapeRowMapper shape, byte value) { shape.Object.PathShearX = value; });
rowMapperSchema.AddMapping<byte>("PathShearY", rowMapperSchema.AddMapping<byte>("PathShearY",
delegate(PrimitiveBaseShapeRowMapper shape) { return shape.Object.PathShearY; }, delegate(PrimitiveBaseShapeRowMapper shape) { return shape.Object.PathShearY; },
delegate(PrimitiveBaseShapeRowMapper shape, byte value) { shape.Object.PathShearY = value; }); delegate(PrimitiveBaseShapeRowMapper shape, byte value) { shape.Object.PathShearY = value; });
rowMapperSchema.AddMapping<ushort>("ProfileBegin", rowMapperSchema.AddMapping<ushort>("ProfileBegin",
delegate(PrimitiveBaseShapeRowMapper shape) { return shape.Object.ProfileBegin; }, delegate(PrimitiveBaseShapeRowMapper shape) { return shape.Object.ProfileBegin; },
delegate(PrimitiveBaseShapeRowMapper shape, ushort value) { shape.Object.ProfileBegin = value; }); delegate(PrimitiveBaseShapeRowMapper shape, ushort value) { shape.Object.ProfileBegin = value; });
rowMapperSchema.AddMapping<ushort>("ProfileEnd", rowMapperSchema.AddMapping<ushort>("ProfileEnd",
delegate(PrimitiveBaseShapeRowMapper shape) { return shape.Object.ProfileEnd; }, delegate(PrimitiveBaseShapeRowMapper shape) { return shape.Object.ProfileEnd; },
delegate(PrimitiveBaseShapeRowMapper shape, ushort value) { shape.Object.ProfileEnd = value; }); delegate(PrimitiveBaseShapeRowMapper shape, ushort value) { shape.Object.ProfileEnd = value; });
rowMapperSchema.AddMapping<LLVector3>("Scale", rowMapperSchema.AddMapping<LLVector3>("Scale",
delegate(PrimitiveBaseShapeRowMapper shape) { return shape.Object.Scale; }, delegate(PrimitiveBaseShapeRowMapper shape) { return shape.Object.Scale; },
delegate(PrimitiveBaseShapeRowMapper shape, LLVector3 value) { shape.Object.Scale = value; }); delegate(PrimitiveBaseShapeRowMapper shape, LLVector3 value) { shape.Object.Scale = value; });
rowMapperSchema.AddMapping<sbyte>("PathTaperX", rowMapperSchema.AddMapping<sbyte>("PathTaperX",
delegate(PrimitiveBaseShapeRowMapper shape) { return shape.Object.PathTaperX; }, delegate(PrimitiveBaseShapeRowMapper shape) { return shape.Object.PathTaperX; },
delegate(PrimitiveBaseShapeRowMapper shape, sbyte value) { shape.Object.PathTaperX = value; }); delegate(PrimitiveBaseShapeRowMapper shape, sbyte value) { shape.Object.PathTaperX = value; });
rowMapperSchema.AddMapping<sbyte>("PathTaperY", rowMapperSchema.AddMapping<sbyte>("PathTaperY",
delegate(PrimitiveBaseShapeRowMapper shape) { return shape.Object.PathTaperY; }, delegate(PrimitiveBaseShapeRowMapper shape) { return shape.Object.PathTaperY; },
delegate(PrimitiveBaseShapeRowMapper shape, sbyte value) { shape.Object.PathTaperY = value; }); delegate(PrimitiveBaseShapeRowMapper shape, sbyte value) { shape.Object.PathTaperY = value; });
rowMapperSchema.AddMapping<sbyte>("PathTwist", rowMapperSchema.AddMapping<sbyte>("PathTwist",
delegate(PrimitiveBaseShapeRowMapper shape) { return shape.Object.PathTwist; }, delegate(PrimitiveBaseShapeRowMapper shape) { return shape.Object.PathTwist; },
delegate(PrimitiveBaseShapeRowMapper shape, sbyte value) { shape.Object.PathTwist = value; }); delegate(PrimitiveBaseShapeRowMapper shape, sbyte value) { shape.Object.PathTwist = value; });
rowMapperSchema.AddMapping<sbyte>("PathRadiusOffset", rowMapperSchema.AddMapping<sbyte>("PathRadiusOffset",
delegate(PrimitiveBaseShapeRowMapper shape) { return shape.Object.PathRadiusOffset; }, delegate(PrimitiveBaseShapeRowMapper shape) { return shape.Object.PathRadiusOffset; },
delegate(PrimitiveBaseShapeRowMapper shape, sbyte value) { shape.Object.PathRadiusOffset = value; }); delegate(PrimitiveBaseShapeRowMapper shape, sbyte value) { shape.Object.PathRadiusOffset = value; });
rowMapperSchema.AddMapping<byte>("PathRevolutions", rowMapperSchema.AddMapping<byte>("PathRevolutions",
delegate(PrimitiveBaseShapeRowMapper shape) { return shape.Object.PathRevolutions; }, delegate(PrimitiveBaseShapeRowMapper shape) { return shape.Object.PathRevolutions; },
delegate(PrimitiveBaseShapeRowMapper shape, byte value) { shape.Object.PathRevolutions = value; }); delegate(PrimitiveBaseShapeRowMapper shape, byte value) { shape.Object.PathRevolutions = value; });
rowMapperSchema.AddMapping<sbyte>("PathTwistBegin", rowMapperSchema.AddMapping<sbyte>("PathTwistBegin",
delegate(PrimitiveBaseShapeRowMapper shape) { return shape.Object.PathTwistBegin; }, delegate(PrimitiveBaseShapeRowMapper shape) { return shape.Object.PathTwistBegin; },
delegate(PrimitiveBaseShapeRowMapper shape, sbyte value) { shape.Object.PathTwistBegin = value; }); delegate(PrimitiveBaseShapeRowMapper shape, sbyte value) { shape.Object.PathTwistBegin = value; });
rowMapperSchema.AddMapping<byte>("PathCurve", rowMapperSchema.AddMapping<byte>("PathCurve",
delegate(PrimitiveBaseShapeRowMapper shape) { return shape.Object.PathCurve; }, delegate(PrimitiveBaseShapeRowMapper shape) { return shape.Object.PathCurve; },
delegate(PrimitiveBaseShapeRowMapper shape, byte value) { shape.Object.PathCurve = value; }); delegate(PrimitiveBaseShapeRowMapper shape, byte value) { shape.Object.PathCurve = value; });
rowMapperSchema.AddMapping<byte>("ProfileCurve", rowMapperSchema.AddMapping<byte>("ProfileCurve",
delegate(PrimitiveBaseShapeRowMapper shape) { return shape.Object.ProfileCurve; }, delegate(PrimitiveBaseShapeRowMapper shape) { return shape.Object.ProfileCurve; },
delegate(PrimitiveBaseShapeRowMapper shape, byte value) { shape.Object.ProfileCurve = value; }); delegate(PrimitiveBaseShapeRowMapper shape, byte value) { shape.Object.ProfileCurve = value; });
rowMapperSchema.AddMapping<ushort>("ProfileHollow", rowMapperSchema.AddMapping<ushort>("ProfileHollow",
delegate(PrimitiveBaseShapeRowMapper shape) { return shape.Object.ProfileHollow; }, delegate(PrimitiveBaseShapeRowMapper shape) { return shape.Object.ProfileHollow; },
delegate(PrimitiveBaseShapeRowMapper shape, ushort value) { shape.Object.ProfileHollow = value; }); delegate(PrimitiveBaseShapeRowMapper shape, ushort value) { shape.Object.ProfileHollow = value; });
rowMapperSchema.AddMapping<byte[]>("TextureEntry", rowMapperSchema.AddMapping<byte[]>("TextureEntry",
delegate(PrimitiveBaseShapeRowMapper shape) { return shape.Object.TextureEntry; }, delegate(PrimitiveBaseShapeRowMapper shape) { return shape.Object.TextureEntry; },
delegate(PrimitiveBaseShapeRowMapper shape, byte[] value) { shape.Object.TextureEntry = value; }); delegate(PrimitiveBaseShapeRowMapper shape, byte[] value) { shape.Object.TextureEntry = value; });
rowMapperSchema.AddMapping<byte[]>("ExtraParams", rowMapperSchema.AddMapping<byte[]>("ExtraParams",
delegate(PrimitiveBaseShapeRowMapper shape) { return shape.Object.ExtraParams; }, delegate(PrimitiveBaseShapeRowMapper shape) { return shape.Object.ExtraParams; },
delegate(PrimitiveBaseShapeRowMapper shape, byte[] value) { shape.Object.ExtraParams = value; }); delegate(PrimitiveBaseShapeRowMapper shape, byte[] value) { shape.Object.ExtraParams = value; });
} }
public override PrimitiveBaseShapeRowMapper FromReader(DataReader reader) public override PrimitiveBaseShapeRowMapper FromReader(DataReader reader)
{ {
PrimitiveBaseShape shape = new PrimitiveBaseShape(); PrimitiveBaseShape shape = new PrimitiveBaseShape();
PrimitiveBaseShapeRowMapper mapper = new PrimitiveBaseShapeRowMapper(m_schema, shape); PrimitiveBaseShapeRowMapper mapper = new PrimitiveBaseShapeRowMapper(m_schema, shape);
mapper.FillObject( reader ); mapper.FillObject( reader );
return mapper; return mapper;
} }
public bool Update(Guid sceneObjectPartId, PrimitiveBaseShape primitiveBaseShape) public bool Update(Guid sceneObjectPartId, PrimitiveBaseShape primitiveBaseShape)
{ {
PrimitiveBaseShapeRowMapper mapper = CreateRowMapper(sceneObjectPartId, primitiveBaseShape); PrimitiveBaseShapeRowMapper mapper = CreateRowMapper(sceneObjectPartId, primitiveBaseShape);
return Update(sceneObjectPartId, mapper); return Update(sceneObjectPartId, mapper);
} }
public bool Add(Guid sceneObjectPartId, PrimitiveBaseShape primitiveBaseShape) public bool Add(Guid sceneObjectPartId, PrimitiveBaseShape primitiveBaseShape)
{ {
PrimitiveBaseShapeRowMapper mapper = CreateRowMapper(sceneObjectPartId, primitiveBaseShape); PrimitiveBaseShapeRowMapper mapper = CreateRowMapper(sceneObjectPartId, primitiveBaseShape);
return Add(mapper); return Add(mapper);
} }
private PrimitiveBaseShapeRowMapper CreateRowMapper(Guid sceneObjectPartId, PrimitiveBaseShape primitiveBaseShape) private PrimitiveBaseShapeRowMapper CreateRowMapper(Guid sceneObjectPartId, PrimitiveBaseShape primitiveBaseShape)
{ {
PrimitiveBaseShapeRowMapper mapper = new PrimitiveBaseShapeRowMapper( m_schema, primitiveBaseShape ); PrimitiveBaseShapeRowMapper mapper = new PrimitiveBaseShapeRowMapper( m_schema, primitiveBaseShape );
mapper.SceneObjectPartId = sceneObjectPartId; mapper.SceneObjectPartId = sceneObjectPartId;
return mapper; return mapper;
} }
} }
} }