aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorlbsa712008-01-15 10:15:39 +0000
committerlbsa712008-01-15 10:15:39 +0000
commit47c65295236560b0c58c1797ce2ad19418fa2b94 (patch)
tree1aacd2f02d5c6a585a9fc61e0b3c57ae6beaf1d9
parent* Delinking doesn't leave invisible physical objects behind anymore (diff)
downloadopensim-SC-47c65295236560b0c58c1797ce2ad19418fa2b94.zip
opensim-SC-47c65295236560b0c58c1797ce2ad19418fa2b94.tar.gz
opensim-SC-47c65295236560b0c58c1797ce2ad19418fa2b94.tar.bz2
opensim-SC-47c65295236560b0c58c1797ce2ad19418fa2b94.tar.xz
* Some morw work on specializing the database framework for OpenSim
-rw-r--r--OpenSim/Framework/Data/OpenSimObjectFieldMapper.cs3
-rw-r--r--OpenSim/Framework/Data/OpenSimTableMapper.cs17
-rw-r--r--OpenSim/Framework/Data/PrimitiveBaseShapeTableMapper.cs4
-rw-r--r--ThirdParty/TribalMedia/TribalMedia.Framework.Data/ObjectTableMapper.cs9
-rw-r--r--ThirdParty/TribalMedia/TribalMedia.Framework.Data/TableMapper.cs25
5 files changed, 40 insertions, 18 deletions
diff --git a/OpenSim/Framework/Data/OpenSimObjectFieldMapper.cs b/OpenSim/Framework/Data/OpenSimObjectFieldMapper.cs
index b718fe4..851ebcd 100644
--- a/OpenSim/Framework/Data/OpenSimObjectFieldMapper.cs
+++ b/OpenSim/Framework/Data/OpenSimObjectFieldMapper.cs
@@ -1,5 +1,6 @@
1using System; 1using System;
2using System.Collections.Generic; 2using System.Collections.Generic;
3using System.Data.Common;
3using System.Text; 4using System.Text;
4using libsecondlife; 5using libsecondlife;
5using TribalMedia.Framework.Data; 6using TribalMedia.Framework.Data;
@@ -15,7 +16,7 @@ namespace OpenSim.Framework.Data
15 { 16 {
16 } 17 }
17 18
18 public override void ExpandField<TObj>(TObj obj, System.Data.Common.DbCommand command, List<string> fieldNames) 19 public override void ExpandField<TObj>(TObj obj, DbCommand command, List<string> fieldNames)
19 { 20 {
20 string fieldName = FieldName; 21 string fieldName = FieldName;
21 object value = GetParamValue(obj); 22 object value = GetParamValue(obj);
diff --git a/OpenSim/Framework/Data/OpenSimTableMapper.cs b/OpenSim/Framework/Data/OpenSimTableMapper.cs
new file mode 100644
index 0000000..c72f523
--- /dev/null
+++ b/OpenSim/Framework/Data/OpenSimTableMapper.cs
@@ -0,0 +1,17 @@
1using System.Data;
2using TribalMedia.Framework.Data;
3
4namespace OpenSim.Framework.Data
5{
6 public abstract class OpenSimTableMapper<TRowMapper, TPrimaryKey> : ObjectTableMapper<TRowMapper, TPrimaryKey>
7 {
8 public OpenSimTableMapper(DatabaseMapper database, string tableName) : base(database, tableName)
9 {
10 }
11
12 protected override DataReader CreateReader(IDataReader reader)
13 {
14 return new OpenSimDataReader(reader);
15 }
16 }
17}
diff --git a/OpenSim/Framework/Data/PrimitiveBaseShapeTableMapper.cs b/OpenSim/Framework/Data/PrimitiveBaseShapeTableMapper.cs
index ab0115e..c8098ab 100644
--- a/OpenSim/Framework/Data/PrimitiveBaseShapeTableMapper.cs
+++ b/OpenSim/Framework/Data/PrimitiveBaseShapeTableMapper.cs
@@ -14,7 +14,7 @@ namespace OpenSim.Framework.Data
14 } 14 }
15 } 15 }
16 16
17 public class PrimitiveBaseShapeTableMapper : ObjectTableMapper<PrimitiveBaseShapeRowMapper, Guid> 17 public class PrimitiveBaseShapeTableMapper : OpenSimTableMapper<PrimitiveBaseShapeRowMapper, Guid>
18 { 18 {
19 public PrimitiveBaseShapeTableMapper(DatabaseMapper connection, string tableName) 19 public PrimitiveBaseShapeTableMapper(DatabaseMapper connection, string tableName)
20 : base(connection, tableName) 20 : base(connection, tableName)
@@ -140,4 +140,4 @@ namespace OpenSim.Framework.Data
140 return mapper; 140 return mapper;
141 } 141 }
142 } 142 }
143} \ No newline at end of file 143}
diff --git a/ThirdParty/TribalMedia/TribalMedia.Framework.Data/ObjectTableMapper.cs b/ThirdParty/TribalMedia/TribalMedia.Framework.Data/ObjectTableMapper.cs
index 818c530..f2ee4f8 100644
--- a/ThirdParty/TribalMedia/TribalMedia.Framework.Data/ObjectTableMapper.cs
+++ b/ThirdParty/TribalMedia/TribalMedia.Framework.Data/ObjectTableMapper.cs
@@ -32,8 +32,8 @@ namespace TribalMedia.Framework.Data
32{ 32{
33 public abstract class ObjectTableMapper<TRowMapper, TPrimaryKey> : TableMapper 33 public abstract class ObjectTableMapper<TRowMapper, TPrimaryKey> : TableMapper
34 { 34 {
35 public ObjectTableMapper(DatabaseMapper connectionPool, string tableName) 35 public ObjectTableMapper(DatabaseMapper database, string tableName)
36 : base(connectionPool, tableName) 36 : base(database, tableName)
37 { 37 {
38 } 38 }
39 39
@@ -52,7 +52,7 @@ namespace TribalMedia.Framework.Data
52 { 52 {
53 if (reader.Read()) 53 if (reader.Read())
54 { 54 {
55 result = FromReader(new DataReader(reader)); 55 result = FromReader( CreateReader(reader));
56 success = true; 56 success = true;
57 } 57 }
58 else 58 else
@@ -67,8 +67,7 @@ namespace TribalMedia.Framework.Data
67 67
68 return success; 68 return success;
69 } 69 }
70 70
71
72 public virtual bool Remove(TPrimaryKey id) 71 public virtual bool Remove(TPrimaryKey id)
73 { 72 {
74 int deleted = 0; 73 int deleted = 0;
diff --git a/ThirdParty/TribalMedia/TribalMedia.Framework.Data/TableMapper.cs b/ThirdParty/TribalMedia/TribalMedia.Framework.Data/TableMapper.cs
index 480a015..a2b0aa1 100644
--- a/ThirdParty/TribalMedia/TribalMedia.Framework.Data/TableMapper.cs
+++ b/ThirdParty/TribalMedia/TribalMedia.Framework.Data/TableMapper.cs
@@ -33,14 +33,14 @@ namespace TribalMedia.Framework.Data
33{ 33{
34 public abstract class TableMapper 34 public abstract class TableMapper
35 { 35 {
36 private readonly DatabaseMapper m_connectionPool; 36 private readonly DatabaseMapper m_database;
37 private readonly object m_syncRoot = new object(); 37 private readonly object m_syncRoot = new object();
38 38
39 protected void WithConnection(Action<DbConnection> action) 39 protected void WithConnection(Action<DbConnection> action)
40 { 40 {
41 lock (m_syncRoot) 41 lock (m_syncRoot)
42 { 42 {
43 DbConnection m_connection = m_connectionPool.GetNewConnection(); 43 DbConnection m_connection = m_database.GetNewConnection();
44 44
45 if (m_connection.State != ConnectionState.Open) 45 if (m_connection.State != ConnectionState.Open)
46 { 46 {
@@ -74,40 +74,45 @@ namespace TribalMedia.Framework.Data
74 get { return m_keyFieldMapper; } 74 get { return m_keyFieldMapper; }
75 } 75 }
76 76
77 public TableMapper(DatabaseMapper connectionPool, string tableName) 77 public TableMapper(DatabaseMapper database, string tableName)
78 { 78 {
79 m_connectionPool = connectionPool; 79 m_database = database;
80 m_tableName = tableName.ToLower(); // Stupid MySQL hack. 80 m_tableName = tableName.ToLower(); // Stupid MySQL hack.
81 } 81 }
82 82
83 public string CreateParamName(string fieldName) 83 public string CreateParamName(string fieldName)
84 { 84 {
85 return m_connectionPool.CreateParamName(fieldName); 85 return m_database.CreateParamName(fieldName);
86 } 86 }
87 87
88 protected DbCommand CreateSelectCommand(DbConnection connection, string fieldName, object primaryKey) 88 protected DbCommand CreateSelectCommand(DbConnection connection, string fieldName, object primaryKey)
89 { 89 {
90 return m_connectionPool.CreateSelectCommand(this, connection, fieldName, primaryKey); 90 return m_database.CreateSelectCommand(this, connection, fieldName, primaryKey);
91 } 91 }
92 92
93 public string CreateCondition(DbCommand command, string fieldName, object key) 93 public string CreateCondition(DbCommand command, string fieldName, object key)
94 { 94 {
95 return m_connectionPool.CreateCondition(this, command, fieldName, key); 95 return m_database.CreateCondition(this, command, fieldName, key);
96 } 96 }
97 97
98 public DbCommand CreateInsertCommand(DbConnection connection, object obj) 98 public DbCommand CreateInsertCommand(DbConnection connection, object obj)
99 { 99 {
100 return m_connectionPool.CreateInsertCommand(this, connection, obj); 100 return m_database.CreateInsertCommand(this, connection, obj);
101 } 101 }
102 102
103 public DbCommand CreateUpdateCommand(DbConnection connection, object rowMapper, object primaryKey) 103 public DbCommand CreateUpdateCommand(DbConnection connection, object rowMapper, object primaryKey)
104 { 104 {
105 return m_connectionPool.CreateUpdateCommand(this, connection, rowMapper, primaryKey); 105 return m_database.CreateUpdateCommand(this, connection, rowMapper, primaryKey);
106 } 106 }
107 107
108 public object ConvertToDbType(object value) 108 public object ConvertToDbType(object value)
109 { 109 {
110 return m_connectionPool.ConvertToDbType(value); 110 return m_database.ConvertToDbType(value);
111 }
112
113 protected virtual DataReader CreateReader(IDataReader reader)
114 {
115 return new DataReader(reader);
111 } 116 }
112 } 117 }
113} \ No newline at end of file 118} \ No newline at end of file