From d96caaa14e9e869e85eecc6b760221ad0579f68e Mon Sep 17 00:00:00 2001
From: Jeff Ames
Date: Thu, 26 Jun 2008 20:20:30 +0000
Subject: Apply patch from bug #1606 -- Documentation for Data/Null, Data/Base.
Thanks kerunix_Flan!
---
OpenSim/Data/Base/AppearanceTableMapper.cs | 44 +++++++++
OpenSim/Data/Base/BaseDataReader.cs | 66 +++++++++++++
OpenSim/Data/Base/BaseDatabaseConnector.cs | 43 ++++++++
OpenSim/Data/Base/BaseFieldMapper.cs | 46 +++++++++
OpenSim/Data/Base/BaseRowMapper.cs | 19 ++++
OpenSim/Data/Base/BaseSchema.cs | 26 +++++
OpenSim/Data/Base/BaseTableMapper.cs | 151 ++++++++++++++++++++++++++---
OpenSim/Data/Null/NullDataStore.cs | 3 +
8 files changed, 382 insertions(+), 16 deletions(-)
(limited to 'OpenSim')
diff --git a/OpenSim/Data/Base/AppearanceTableMapper.cs b/OpenSim/Data/Base/AppearanceTableMapper.cs
index 60acfe0..7964880 100644
--- a/OpenSim/Data/Base/AppearanceTableMapper.cs
+++ b/OpenSim/Data/Base/AppearanceTableMapper.cs
@@ -32,6 +32,9 @@ using OpenSim.Framework;
namespace OpenSim.Data.Base
{
+ ///
+ ///
+ ///
public class AppearanceRowMapper : BaseRowMapper
{
public AppearanceRowMapper(BaseSchema schema, AvatarAppearance obj)
@@ -40,6 +43,9 @@ namespace OpenSim.Data.Base
}
}
+ ///
+ ///
+ ///
public class AppearanceTableMapper : BaseTableMapper
{
public AppearanceTableMapper(BaseDatabaseConnector database, string tableName)
@@ -186,28 +192,55 @@ namespace OpenSim.Data.Base
}
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
public bool Add(Guid userID, AvatarAppearance appearance)
{
AppearanceRowMapper mapper = CreateRowMapper(appearance);
return Add(mapper);
}
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
public bool Update(Guid userID, AvatarAppearance appearance)
{
AppearanceRowMapper mapper = CreateRowMapper(appearance);
return Update(appearance.Owner.UUID, mapper);
}
+ ///
+ ///
+ ///
+ ///
+ ///
protected AppearanceRowMapper CreateRowMapper(AvatarAppearance appearance)
{
return new AppearanceRowMapper(m_schema, appearance);
}
+ ///
+ ///
+ ///
+ ///
protected AppearanceRowMapper CreateRowMapper()
{
return CreateRowMapper(new AvatarAppearance());
}
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
protected AppearanceRowMapper FromReader(BaseDataReader reader, AvatarAppearance appearance)
{
AppearanceRowMapper mapper = CreateRowMapper(appearance);
@@ -215,6 +248,11 @@ namespace OpenSim.Data.Base
return mapper;
}
+ ///
+ ///
+ ///
+ ///
+ ///
public override AppearanceRowMapper FromReader(BaseDataReader reader)
{
AppearanceRowMapper mapper = CreateRowMapper();
@@ -222,6 +260,12 @@ namespace OpenSim.Data.Base
return mapper;
}
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
public bool TryGetValue(Guid presenceID, out AvatarAppearance val)
{
AppearanceRowMapper mapper;
diff --git a/OpenSim/Data/Base/BaseDataReader.cs b/OpenSim/Data/Base/BaseDataReader.cs
index 517f672..23f03e5 100644
--- a/OpenSim/Data/Base/BaseDataReader.cs
+++ b/OpenSim/Data/Base/BaseDataReader.cs
@@ -31,25 +31,47 @@ using System.IO;
namespace OpenSim.Data.Base
{
+ ///
+ ///
+ ///
public abstract class BaseDataReader
{
private readonly IDataReader m_source;
+ ///
+ ///
+ ///
+ ///
public BaseDataReader(IDataReader source)
{
m_source = source;
}
+ ///
+ ///
+ ///
+ ///
+ ///
public object Get(string name)
{
return m_source[name];
}
+ ///
+ ///
+ ///
+ ///
+ ///
public ushort GetUShort(string name)
{
return (ushort)m_source.GetInt32(m_source.GetOrdinal(name));
}
+ ///
+ ///
+ ///
+ ///
+ ///
public byte GetByte(string name)
{
int ordinal = m_source.GetOrdinal(name);
@@ -57,16 +79,31 @@ namespace OpenSim.Data.Base
return value;
}
+ ///
+ ///
+ ///
+ ///
+ ///
public sbyte GetSByte(string name)
{
return (sbyte)m_source.GetInt16(m_source.GetOrdinal(name));
}
+ ///
+ ///
+ ///
+ ///
+ ///
public float GetFloat(string name)
{
return m_source.GetFloat(m_source.GetOrdinal(name));
}
+ ///
+ ///
+ ///
+ ///
+ ///
public byte[] GetBytes(string name)
{
int ordinal = m_source.GetOrdinal(name);
@@ -94,6 +131,11 @@ namespace OpenSim.Data.Base
return memStream.ToArray();
}
+ ///
+ ///
+ ///
+ ///
+ ///
public string GetString(string name)
{
int ordinal = m_source.GetOrdinal(name);
@@ -107,21 +149,40 @@ namespace OpenSim.Data.Base
return (string)value;
}
+ ///
+ ///
+ ///
+ ///
public bool Read()
{
return m_source.Read();
}
+ ///
+ ///
+ ///
+ ///
+ ///
public virtual Guid GetGuid(string name)
{
return m_source.GetGuid(m_source.GetOrdinal(name));
}
+ ///
+ ///
+ ///
+ ///
+ ///
public UInt32 GetUInt32(string name)
{
return (UInt32)GetInt32(name);
}
+ ///
+ ///
+ ///
+ ///
+ ///
private Int32 GetInt32(string name)
{
int ordinal = m_source.GetOrdinal(name);
@@ -129,6 +190,11 @@ namespace OpenSim.Data.Base
return int32;
}
+ ///
+ ///
+ ///
+ ///
+ ///
public Int64 GetInt64(string name)
{
int ordinal = m_source.GetOrdinal(name);
diff --git a/OpenSim/Data/Base/BaseDatabaseConnector.cs b/OpenSim/Data/Base/BaseDatabaseConnector.cs
index 6988839..542004c 100644
--- a/OpenSim/Data/Base/BaseDatabaseConnector.cs
+++ b/OpenSim/Data/Base/BaseDatabaseConnector.cs
@@ -32,10 +32,17 @@ using System.Data.Common;
namespace OpenSim.Data.Base
{
+ ///
+ ///
+ ///
public abstract class BaseDatabaseConnector
{
protected string m_connectionString;
+ ///
+ ///
+ ///
+ ///
public BaseDatabaseConnector(string connectionString)
{
m_connectionString = connectionString;
@@ -44,6 +51,14 @@ namespace OpenSim.Data.Base
public abstract DbConnection GetNewConnection();
public abstract string CreateParamName(string fieldName);
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
public DbCommand CreateSelectCommand(BaseTableMapper mapper, DbConnection connection, string fieldName, object key)
{
string table = mapper.TableName;
@@ -61,6 +76,14 @@ namespace OpenSim.Data.Base
return command;
}
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
public string CreateCondition(BaseTableMapper mapper, DbCommand command, string fieldName, object key)
{
string keyFieldParamName = mapper.CreateParamName(fieldName);
@@ -73,6 +96,14 @@ namespace OpenSim.Data.Base
return String.Format("{0}={1}", fieldName, keyFieldParamName);
}
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
public DbCommand CreateUpdateCommand(BaseTableMapper mapper, DbConnection connection, object rowMapper, object primaryKey)
{
string table = mapper.TableName;
@@ -105,6 +136,13 @@ namespace OpenSim.Data.Base
return command;
}
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
public DbCommand CreateInsertCommand(BaseTableMapper mapper, DbConnection connection, object obj)
{
string table = mapper.TableName;
@@ -132,6 +170,11 @@ namespace OpenSim.Data.Base
return command;
}
+ ///
+ ///
+ ///
+ ///
+ ///
public virtual object ConvertToDbType(object value)
{
return value;
diff --git a/OpenSim/Data/Base/BaseFieldMapper.cs b/OpenSim/Data/Base/BaseFieldMapper.cs
index 4fdc7b9..c7d6bc9 100644
--- a/OpenSim/Data/Base/BaseFieldMapper.cs
+++ b/OpenSim/Data/Base/BaseFieldMapper.cs
@@ -34,11 +34,17 @@ namespace OpenSim.Data.Base
public delegate TField ObjectGetAccessor(TObj obj);
public delegate void ObjectSetAccessor(TObj obj, TField value);
+ ///
+ ///
+ ///
public abstract class BaseFieldMapper
{
private readonly BaseTableMapper m_tableMapper;
private readonly string m_fieldName;
+ ///
+ ///
+ ///
public string FieldName
{
get { return m_fieldName; }
@@ -46,6 +52,9 @@ namespace OpenSim.Data.Base
protected Type m_valueType;
+ ///
+ ///
+ ///
public Type ValueType
{
get { return m_valueType; }
@@ -53,6 +62,12 @@ namespace OpenSim.Data.Base
public abstract object GetParamValue(object obj);
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
public BaseFieldMapper(BaseTableMapper tableMapper, string fieldName, Type valueType)
{
m_fieldName = fieldName;
@@ -62,6 +77,13 @@ namespace OpenSim.Data.Base
public abstract void SetPropertyFromReader(object mapper, BaseDataReader reader);
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
public void RawAddParam(DbCommand command, List fieldNames, string fieldName, object value)
{
string paramName = m_tableMapper.CreateParamName(fieldName);
@@ -74,6 +96,13 @@ namespace OpenSim.Data.Base
command.Parameters.Add(param);
}
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
public virtual void ExpandField(TObj obj, DbCommand command, List fieldNames)
{
string fieldName = FieldName;
@@ -82,6 +111,11 @@ namespace OpenSim.Data.Base
RawAddParam(command, fieldNames, fieldName, m_tableMapper.ConvertToDbType(value));
}
+ ///
+ ///
+ ///
+ ///
+ ///
protected virtual object GetValue(BaseDataReader reader)
{
object value;
@@ -130,6 +164,11 @@ namespace OpenSim.Data.Base
}
}
+ ///
+ ///
+ ///
+ ///
+ ///
public class ObjectField : BaseFieldMapper
{
private readonly ObjectGetAccessor m_fieldGetAccessor;
@@ -157,6 +196,13 @@ namespace OpenSim.Data.Base
}
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
public ObjectField(BaseTableMapper tableMapper, string fieldName, ObjectGetAccessor rowMapperGetAccessor,
ObjectSetAccessor rowMapperSetAccessor)
: base(tableMapper, fieldName, typeof(TField))
diff --git a/OpenSim/Data/Base/BaseRowMapper.cs b/OpenSim/Data/Base/BaseRowMapper.cs
index a61ce49d..d07f9b3 100644
--- a/OpenSim/Data/Base/BaseRowMapper.cs
+++ b/OpenSim/Data/Base/BaseRowMapper.cs
@@ -27,27 +27,46 @@
namespace OpenSim.Data.Base
{
+ ///
+ ///
+ ///
public abstract class BaseRowMapper
{
public abstract void FillObject(BaseDataReader reader);
}
+ ///
+ ///
+ ///
+ ///
public class BaseRowMapper : BaseRowMapper
{
private readonly BaseSchema m_schema;
private readonly TObj m_obj;
+ ///
+ ///
+ ///
public TObj Object
{
get { return m_obj; }
}
+ ///
+ ///
+ ///
+ ///
+ ///
public BaseRowMapper(BaseSchema schema, TObj obj)
{
m_schema = schema;
m_obj = obj;
}
+ ///
+ ///
+ ///
+ ///
public override void FillObject(BaseDataReader reader)
{
foreach (BaseFieldMapper fieldMapper in m_schema.Fields.Values)
diff --git a/OpenSim/Data/Base/BaseSchema.cs b/OpenSim/Data/Base/BaseSchema.cs
index 656433f..9d69a40 100644
--- a/OpenSim/Data/Base/BaseSchema.cs
+++ b/OpenSim/Data/Base/BaseSchema.cs
@@ -29,16 +29,26 @@ using System.Collections.Generic;
namespace OpenSim.Data.Base
{
+ ///
+ ///
+ ///
public class BaseSchema
{
protected BaseTableMapper m_tableMapper;
protected Dictionary m_mappings;
+ ///
+ ///
+ ///
public Dictionary Fields
{
get { return m_mappings; }
}
+ ///
+ ///
+ ///
+ ///
public BaseSchema(BaseTableMapper tableMapper)
{
m_mappings = new Dictionary();
@@ -46,13 +56,29 @@ namespace OpenSim.Data.Base
}
}
+ ///
+ ///
+ ///
+ ///
public class BaseSchema : BaseSchema
{
+ ///
+ ///
+ ///
+ ///
public BaseSchema(BaseTableMapper tableMapper)
: base(tableMapper)
{
}
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
public ObjectField AddMapping(string fieldName,
ObjectGetAccessor rowMapperGetAccessor,
ObjectSetAccessor rowMapperSetAccessor)
diff --git a/OpenSim/Data/Base/BaseTableMapper.cs b/OpenSim/Data/Base/BaseTableMapper.cs
index 649b228..28b7ac8 100644
--- a/OpenSim/Data/Base/BaseTableMapper.cs
+++ b/OpenSim/Data/Base/BaseTableMapper.cs
@@ -31,11 +31,18 @@ using System.Data.Common;
namespace OpenSim.Data.Base
{
+ ///
+ ///
+ ///
public abstract class BaseTableMapper
{
private readonly BaseDatabaseConnector m_database;
private readonly object m_syncRoot = new object();
+ ///
+ ///
+ ///
+ ///
protected void WithConnection(Action action)
{
lock (m_syncRoot)
@@ -74,59 +81,124 @@ namespace OpenSim.Data.Base
get { return m_keyFieldMapper; }
}
+ ///
+ ///
+ ///
+ ///
+ ///
public BaseTableMapper(BaseDatabaseConnector database, string tableName)
{
m_database = database;
m_tableName = tableName.ToLower(); // Stupid MySQL hack.
}
+ ///
+ ///
+ ///
+ ///
+ ///
public string CreateParamName(string fieldName)
{
return m_database.CreateParamName(fieldName);
}
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
protected DbCommand CreateSelectCommand(DbConnection connection, string fieldName, object primaryKey)
{
return m_database.CreateSelectCommand(this, connection, fieldName, primaryKey);
}
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
public string CreateCondition(DbCommand command, string fieldName, object key)
{
return m_database.CreateCondition(this, command, fieldName, key);
}
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
public DbCommand CreateInsertCommand(DbConnection connection, object obj)
{
return m_database.CreateInsertCommand(this, connection, obj);
}
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
public DbCommand CreateUpdateCommand(DbConnection connection, object rowMapper, object primaryKey)
{
return m_database.CreateUpdateCommand(this, connection, rowMapper, primaryKey);
}
+ ///
+ ///
+ ///
+ ///
+ ///
public object ConvertToDbType(object value)
{
return m_database.ConvertToDbType(value);
}
+ ///
+ ///
+ ///
+ ///
+ ///
protected virtual BaseDataReader CreateReader(IDataReader reader)
{
return m_database.CreateReader(reader);
}
}
+ ///
+ ///
+ ///
+ ///
+ ///
public abstract class BaseTableMapper : BaseTableMapper
{
+ ///
+ ///
+ ///
+ ///
+ ///
public BaseTableMapper(BaseDatabaseConnector database, string tableName)
: base(database, tableName)
{
}
- // HACK: This is a temporary function used by TryGetValue().
- // Due to a bug in mono 1.2.6, delegate blocks cannot contain
- // a using block. This has been fixed in SVN, so the next
- // mono release should work.
+
+
+ ///
+ /// HACK: This is a temporary function used by TryGetValue().
+ /// Due to a bug in mono 1.2.6, delegate blocks cannot contain
+ /// a using block. This has been fixed in SVN, so the next
+ /// mono release should work.
+ ///
+ ///
+ ///
+ ///
+ ///
private void TryGetConnectionValue(DbConnection connection, TPrimaryKey primaryKey, ref TRowMapper result, ref bool success)
{
using (
@@ -148,6 +220,12 @@ namespace OpenSim.Data.Base
}
}
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
public bool TryGetValue(TPrimaryKey primaryKey, out TRowMapper value)
{
TRowMapper result = default(TRowMapper);
@@ -163,10 +241,15 @@ namespace OpenSim.Data.Base
return success;
}
- // HACK: This is a temporary function used by Remove().
- // Due to a bug in mono 1.2.6, delegate blocks cannot contain
- // a using block. This has been fixed in SVN, so the next
- // mono release should work.
+ ///
+ /// HACK: This is a temporary function used by Remove().
+ /// Due to a bug in mono 1.2.6, delegate blocks cannot contain
+ /// a using block. This has been fixed in SVN, so the next
+ /// mono release should work.
+ ///
+ ///
+ ///
+ ///
protected virtual void TryDelete(DbConnection connection, TPrimaryKey id, ref int deleted)
{
using (
@@ -177,6 +260,11 @@ namespace OpenSim.Data.Base
}
}
+ ///
+ ///
+ ///
+ ///
+ ///
public virtual bool Remove(TPrimaryKey id)
{
int deleted = 0;
@@ -196,6 +284,13 @@ namespace OpenSim.Data.Base
}
}
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
public DbCommand CreateDeleteCommand(DbConnection connection, string fieldName, TPrimaryKey primaryKey)
{
string table = TableName;
@@ -213,10 +308,18 @@ namespace OpenSim.Data.Base
return command;
}
- // HACK: This is a temporary function used by Update().
- // Due to a bug in mono 1.2.6, delegate blocks cannot contain
- // a using block. This has been fixed in SVN, so the next
- // mono release should work.
+
+
+ ///
+ /// HACK: This is a temporary function used by Update().
+ /// Due to a bug in mono 1.2.6, delegate blocks cannot contain
+ /// a using block. This has been fixed in SVN, so the next
+ /// mono release should work.
+ ///
+ ///
+ ///
+ ///
+ ///
protected void TryUpdate(DbConnection connection, TPrimaryKey primaryKey, TRowMapper value, ref int updated)
{
using (DbCommand command = CreateUpdateCommand(connection, value, primaryKey))
@@ -225,6 +328,12 @@ namespace OpenSim.Data.Base
}
}
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
public virtual bool Update(TPrimaryKey primaryKey, TRowMapper value)
{
int updated = 0;
@@ -244,10 +353,15 @@ namespace OpenSim.Data.Base
}
}
- // HACK: This is a temporary function used by Add().
- // Due to a bug in mono 1.2.6, delegate blocks cannot contain
- // a using block. This has been fixed in SVN, so the next
- // mono release should work.
+ ///
+ /// HACK: This is a temporary function used by Add().
+ /// Due to a bug in mono 1.2.6, delegate blocks cannot contain
+ /// a using block. This has been fixed in SVN, so the next
+ /// mono release should work.
+ ///
+ ///
+ ///
+ ///
protected void TryAdd(DbConnection connection, TRowMapper value, ref int added)
{
using (DbCommand command = CreateInsertCommand(connection, value))
@@ -256,6 +370,11 @@ namespace OpenSim.Data.Base
}
}
+ ///
+ ///
+ ///
+ ///
+ ///
public virtual bool Add(TRowMapper value)
{
int added = 0;
diff --git a/OpenSim/Data/Null/NullDataStore.cs b/OpenSim/Data/Null/NullDataStore.cs
index 90cf3a1..51e13d6 100644
--- a/OpenSim/Data/Null/NullDataStore.cs
+++ b/OpenSim/Data/Null/NullDataStore.cs
@@ -33,6 +33,9 @@ using OpenSim.Region.Environment.Scenes;
namespace OpenSim.Data.Null
{
+ ///
+ /// NULL DataStore, do not store anything
+ ///
public class NullDataStore : IRegionDataStore
{
public void Initialise(string dbfile, bool persistPrimInventories)
--
cgit v1.1