* Introduced base abstract provider class for GridData

0.6.0-stable
lbsa71 2008-03-28 15:05:06 +00:00
parent ac27d9250d
commit 0e16488ca8
5 changed files with 61 additions and 49 deletions

View File

@ -34,7 +34,7 @@ namespace OpenSim.Framework.Data.DB4o
/// <summary> /// <summary>
/// A grid server storage mechanism employing the DB4o database system /// A grid server storage mechanism employing the DB4o database system
/// </summary> /// </summary>
internal class DB4oGridData : IGridData internal class DB4oGridData : GridDataBase
{ {
/// <summary> /// <summary>
/// The database manager object /// The database manager object
@ -44,7 +44,7 @@ namespace OpenSim.Framework.Data.DB4o
/// <summary> /// <summary>
/// Called when the plugin is first loaded (as constructors are not called) /// Called when the plugin is first loaded (as constructors are not called)
/// </summary> /// </summary>
public void Initialise() override public void Initialise()
{ {
manager = new DB4oGridManager("gridserver.yap"); manager = new DB4oGridManager("gridserver.yap");
} }
@ -57,7 +57,7 @@ namespace OpenSim.Framework.Data.DB4o
/// <param name="c">maximum X coordinate</param> /// <param name="c">maximum X coordinate</param>
/// <param name="d">maximum Y coordinate</param> /// <param name="d">maximum Y coordinate</param>
/// <returns>An array of region profiles</returns> /// <returns>An array of region profiles</returns>
public RegionProfileData[] GetProfilesInRange(uint a, uint b, uint c, uint d) override public RegionProfileData[] GetProfilesInRange(uint a, uint b, uint c, uint d)
{ {
return null; return null;
} }
@ -67,7 +67,7 @@ namespace OpenSim.Framework.Data.DB4o
/// </summary> /// </summary>
/// <param name="handle">The handle to search for</param> /// <param name="handle">The handle to search for</param>
/// <returns>A region profile</returns> /// <returns>A region profile</returns>
public RegionProfileData GetProfileByHandle(ulong handle) override public RegionProfileData GetProfileByHandle(ulong handle)
{ {
lock (manager.simProfiles) lock (manager.simProfiles)
{ {
@ -87,7 +87,7 @@ namespace OpenSim.Framework.Data.DB4o
/// </summary> /// </summary>
/// <param name="uuid">The region ID code</param> /// <param name="uuid">The region ID code</param>
/// <returns>A region profile</returns> /// <returns>A region profile</returns>
public RegionProfileData GetProfileByLLUUID(LLUUID uuid) override public RegionProfileData GetProfileByLLUUID(LLUUID uuid)
{ {
lock (manager.simProfiles) lock (manager.simProfiles)
{ {
@ -98,7 +98,7 @@ namespace OpenSim.Framework.Data.DB4o
"). Total Registered Regions: " + manager.simProfiles.Count); "). Total Registered Regions: " + manager.simProfiles.Count);
} }
public RegionProfileData GetProfileByString(string regionName) override public RegionProfileData GetProfileByString(string regionName)
{ {
throw new Exception("GetProfileByString Not supported in DB4oGridData"); throw new Exception("GetProfileByString Not supported in DB4oGridData");
//return null; //return null;
@ -109,7 +109,7 @@ namespace OpenSim.Framework.Data.DB4o
/// </summary> /// </summary>
/// <param name="profile">The profile to add</param> /// <param name="profile">The profile to add</param>
/// <returns>A dataresponse enum indicating success</returns> /// <returns>A dataresponse enum indicating success</returns>
public DataResponse AddProfile(RegionProfileData profile) override public DataResponse AddProfile(RegionProfileData profile)
{ {
lock (manager.simProfiles) lock (manager.simProfiles)
{ {
@ -131,7 +131,7 @@ namespace OpenSim.Framework.Data.DB4o
/// <param name="handle">The location the region is logging into (unused in Db4o)</param> /// <param name="handle">The location the region is logging into (unused in Db4o)</param>
/// <param name="key">The shared secret</param> /// <param name="key">The shared secret</param>
/// <returns>Authenticated?</returns> /// <returns>Authenticated?</returns>
public bool AuthenticateSim(LLUUID uuid, ulong handle, string key) override public bool AuthenticateSim(LLUUID uuid, ulong handle, string key)
{ {
if (manager.simProfiles[uuid].regionRecvKey == key) if (manager.simProfiles[uuid].regionRecvKey == key)
return true; return true;
@ -141,7 +141,7 @@ namespace OpenSim.Framework.Data.DB4o
/// <summary> /// <summary>
/// Shuts down the database /// Shuts down the database
/// </summary> /// </summary>
public void Close() override public void Close()
{ {
manager = null; manager = null;
} }
@ -160,7 +160,7 @@ namespace OpenSim.Framework.Data.DB4o
/// Returns the providers name /// Returns the providers name
/// </summary> /// </summary>
/// <returns>The name of the storage system</returns> /// <returns>The name of the storage system</returns>
public string getName() override public string getName()
{ {
return "DB4o Grid Provider"; return "DB4o Grid Provider";
} }
@ -169,12 +169,12 @@ namespace OpenSim.Framework.Data.DB4o
/// Returns the providers version /// Returns the providers version
/// </summary> /// </summary>
/// <returns>The version of the storage system</returns> /// <returns>The version of the storage system</returns>
public string getVersion() override public string getVersion()
{ {
return "0.1"; return "0.1";
} }
public ReservationData GetReservationAtPoint(uint x, uint y) override public ReservationData GetReservationAtPoint(uint x, uint y)
{ {
return null; return null;
} }

View File

@ -38,7 +38,7 @@ namespace OpenSim.Framework.Data.MSSQL
/// <summary> /// <summary>
/// A grid data interface for Microsoft SQL Server /// A grid data interface for Microsoft SQL Server
/// </summary> /// </summary>
public class MSSQLGridData : IGridData public class MSSQLGridData : GridDataBase
{ {
private static readonly log4net.ILog m_log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); private static readonly log4net.ILog m_log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
@ -52,7 +52,7 @@ namespace OpenSim.Framework.Data.MSSQL
/// <summary> /// <summary>
/// Initialises the Grid Interface /// Initialises the Grid Interface
/// </summary> /// </summary>
public void Initialise() override public void Initialise()
{ {
IniFile iniFile = new IniFile("mssql_connection.ini"); IniFile iniFile = new IniFile("mssql_connection.ini");
@ -94,7 +94,7 @@ namespace OpenSim.Framework.Data.MSSQL
/// <summary> /// <summary>
/// Shuts down the grid interface /// Shuts down the grid interface
/// </summary> /// </summary>
public void Close() override public void Close()
{ {
database.Close(); database.Close();
} }
@ -103,7 +103,7 @@ namespace OpenSim.Framework.Data.MSSQL
/// Returns the storage system name /// Returns the storage system name
/// </summary> /// </summary>
/// <returns>A string containing the storage system name</returns> /// <returns>A string containing the storage system name</returns>
public string getName() override public string getName()
{ {
return "Sql OpenGridData"; return "Sql OpenGridData";
} }
@ -112,7 +112,7 @@ namespace OpenSim.Framework.Data.MSSQL
/// Returns the storage system version /// Returns the storage system version
/// </summary> /// </summary>
/// <returns>A string containing the storage system version</returns> /// <returns>A string containing the storage system version</returns>
public string getVersion() override public string getVersion()
{ {
return "0.1"; return "0.1";
} }
@ -125,7 +125,7 @@ namespace OpenSim.Framework.Data.MSSQL
/// <param name="c">maximum X coordinate</param> /// <param name="c">maximum X coordinate</param>
/// <param name="d">maximum Y coordinate</param> /// <param name="d">maximum Y coordinate</param>
/// <returns>An array of region profiles</returns> /// <returns>An array of region profiles</returns>
public RegionProfileData[] GetProfilesInRange(uint a, uint b, uint c, uint d) override public RegionProfileData[] GetProfilesInRange(uint a, uint b, uint c, uint d)
{ {
return null; return null;
} }
@ -135,7 +135,7 @@ namespace OpenSim.Framework.Data.MSSQL
/// </summary> /// </summary>
/// <param name="handle">Region location handle</param> /// <param name="handle">Region location handle</param>
/// <returns>Sim profile</returns> /// <returns>Sim profile</returns>
public RegionProfileData GetProfileByHandle(ulong handle) override public RegionProfileData GetProfileByHandle(ulong handle)
{ {
IDataReader reader = null; IDataReader reader = null;
try try
@ -166,7 +166,7 @@ namespace OpenSim.Framework.Data.MSSQL
/// </summary> /// </summary>
/// <param name="uuid">The region UUID</param> /// <param name="uuid">The region UUID</param>
/// <returns>The sim profile</returns> /// <returns>The sim profile</returns>
public RegionProfileData GetProfileByLLUUID(LLUUID uuid) override public RegionProfileData GetProfileByLLUUID(LLUUID uuid)
{ {
Dictionary<string, string> param = new Dictionary<string, string>(); Dictionary<string, string> param = new Dictionary<string, string>();
param["uuid"] = uuid.ToString(); param["uuid"] = uuid.ToString();
@ -185,7 +185,7 @@ namespace OpenSim.Framework.Data.MSSQL
/// </summary> /// </summary>
/// <param name="uuid">The region name search query</param> /// <param name="uuid">The region name search query</param>
/// <returns>The sim profile</returns> /// <returns>The sim profile</returns>
public RegionProfileData GetProfileByString(string regionName) override public RegionProfileData GetProfileByString(string regionName)
{ {
if (regionName.Length > 2) if (regionName.Length > 2)
{ {
@ -226,7 +226,7 @@ namespace OpenSim.Framework.Data.MSSQL
/// </summary> /// </summary>
/// <param name="profile">The profile to add</param> /// <param name="profile">The profile to add</param>
/// <returns>A dataresponse enum indicating success</returns> /// <returns>A dataresponse enum indicating success</returns>
public DataResponse AddProfile(RegionProfileData profile) override public DataResponse AddProfile(RegionProfileData profile)
{ {
try try
{ {
@ -327,7 +327,7 @@ namespace OpenSim.Framework.Data.MSSQL
/// <param name="handle">The attempted regionHandle of the challenger</param> /// <param name="handle">The attempted regionHandle of the challenger</param>
/// <param name="authkey">The secret</param> /// <param name="authkey">The secret</param>
/// <returns>Whether the secret and regionhandle match the database entry for UUID</returns> /// <returns>Whether the secret and regionhandle match the database entry for UUID</returns>
public bool AuthenticateSim(LLUUID uuid, ulong handle, string authkey) override public bool AuthenticateSim(LLUUID uuid, ulong handle, string authkey)
{ {
bool throwHissyFit = false; // Should be true by 1.0 bool throwHissyFit = false; // Should be true by 1.0
@ -358,7 +358,7 @@ namespace OpenSim.Framework.Data.MSSQL
return false; return false;
} }
public ReservationData GetReservationAtPoint(uint x, uint y) override public ReservationData GetReservationAtPoint(uint x, uint y)
{ {
return null; return null;
} }

View File

@ -39,7 +39,7 @@ namespace OpenSim.Framework.Data.MySQL
/// <summary> /// <summary>
/// A MySQL Interface for the Grid Server /// A MySQL Interface for the Grid Server
/// </summary> /// </summary>
public class MySQLGridData : IGridData public class MySQLGridData : GridDataBase
{ {
private static readonly log4net.ILog m_log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); private static readonly log4net.ILog m_log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
@ -51,7 +51,7 @@ namespace OpenSim.Framework.Data.MySQL
/// <summary> /// <summary>
/// Initialises the Grid Interface /// Initialises the Grid Interface
/// </summary> /// </summary>
public void Initialise() override public void Initialise()
{ {
IniFile GridDataMySqlFile = new IniFile("mysql_connection.ini"); IniFile GridDataMySqlFile = new IniFile("mysql_connection.ini");
string settingHostname = GridDataMySqlFile.ParseFileReadValue("hostname"); string settingHostname = GridDataMySqlFile.ParseFileReadValue("hostname");
@ -113,7 +113,7 @@ namespace OpenSim.Framework.Data.MySQL
/// <summary> /// <summary>
/// Shuts down the grid interface /// Shuts down the grid interface
/// </summary> /// </summary>
public void Close() override public void Close()
{ {
database.Close(); database.Close();
} }
@ -122,7 +122,7 @@ namespace OpenSim.Framework.Data.MySQL
/// Returns the plugin name /// Returns the plugin name
/// </summary> /// </summary>
/// <returns>Plugin name</returns> /// <returns>Plugin name</returns>
public string getName() override public string getName()
{ {
return "MySql OpenGridData"; return "MySql OpenGridData";
} }
@ -131,7 +131,7 @@ namespace OpenSim.Framework.Data.MySQL
/// Returns the plugin version /// Returns the plugin version
/// </summary> /// </summary>
/// <returns>Plugin version</returns> /// <returns>Plugin version</returns>
public string getVersion() override public string getVersion()
{ {
return "0.1"; return "0.1";
} }
@ -144,7 +144,7 @@ namespace OpenSim.Framework.Data.MySQL
/// <param name="xmax">Maximum X coordinate</param> /// <param name="xmax">Maximum X coordinate</param>
/// <param name="ymax">Maximum Y coordinate</param> /// <param name="ymax">Maximum Y coordinate</param>
/// <returns></returns> /// <returns></returns>
public RegionProfileData[] GetProfilesInRange(uint xmin, uint ymin, uint xmax, uint ymax) override public RegionProfileData[] GetProfilesInRange(uint xmin, uint ymin, uint xmax, uint ymax)
{ {
try try
{ {
@ -189,7 +189,7 @@ namespace OpenSim.Framework.Data.MySQL
/// </summary> /// </summary>
/// <param name="handle">Region location handle</param> /// <param name="handle">Region location handle</param>
/// <returns>Sim profile</returns> /// <returns>Sim profile</returns>
public RegionProfileData GetProfileByHandle(ulong handle) override public RegionProfileData GetProfileByHandle(ulong handle)
{ {
try try
{ {
@ -221,7 +221,7 @@ namespace OpenSim.Framework.Data.MySQL
/// </summary> /// </summary>
/// <param name="uuid">The region UUID</param> /// <param name="uuid">The region UUID</param>
/// <returns>The sim profile</returns> /// <returns>The sim profile</returns>
public RegionProfileData GetProfileByLLUUID(LLUUID uuid) override public RegionProfileData GetProfileByLLUUID(LLUUID uuid)
{ {
try try
{ {
@ -253,7 +253,7 @@ namespace OpenSim.Framework.Data.MySQL
/// </summary> /// </summary>
/// <param name="uuid">The region name search query</param> /// <param name="uuid">The region name search query</param>
/// <returns>The sim profile</returns> /// <returns>The sim profile</returns>
public RegionProfileData GetProfileByString(string regionName) override public RegionProfileData GetProfileByString(string regionName)
{ {
if (regionName.Length > 2) if (regionName.Length > 2)
{ {
@ -294,7 +294,7 @@ namespace OpenSim.Framework.Data.MySQL
/// </summary> /// </summary>
/// <param name="profile">The profile to add</param> /// <param name="profile">The profile to add</param>
/// <returns>Successful?</returns> /// <returns>Successful?</returns>
public DataResponse AddProfile(RegionProfileData profile) override public DataResponse AddProfile(RegionProfileData profile)
{ {
lock (database) lock (database)
{ {
@ -337,7 +337,7 @@ namespace OpenSim.Framework.Data.MySQL
/// <param name="handle">The attempted regionHandle of the challenger</param> /// <param name="handle">The attempted regionHandle of the challenger</param>
/// <param name="authkey">The secret</param> /// <param name="authkey">The secret</param>
/// <returns>Whether the secret and regionhandle match the database entry for UUID</returns> /// <returns>Whether the secret and regionhandle match the database entry for UUID</returns>
public bool AuthenticateSim(LLUUID uuid, ulong handle, string authkey) override public bool AuthenticateSim(LLUUID uuid, ulong handle, string authkey)
{ {
bool throwHissyFit = false; // Should be true by 1.0 bool throwHissyFit = false; // Should be true by 1.0
@ -369,7 +369,7 @@ namespace OpenSim.Framework.Data.MySQL
return false; return false;
} }
public ReservationData GetReservationAtPoint(uint x, uint y) override public ReservationData GetReservationAtPoint(uint x, uint y)
{ {
try try
{ {

View File

@ -37,7 +37,7 @@ namespace OpenSim.Framework.Data.SQLite
/// <summary> /// <summary>
/// A Grid Interface to the SQLite database /// A Grid Interface to the SQLite database
/// </summary> /// </summary>
public class SQLiteGridData : IGridData public class SQLiteGridData : GridDataBase
{ {
/// <summary> /// <summary>
/// A database manager /// A database manager
@ -47,7 +47,7 @@ namespace OpenSim.Framework.Data.SQLite
/// <summary> /// <summary>
/// Initialises the Grid Interface /// Initialises the Grid Interface
/// </summary> /// </summary>
public void Initialise() override public void Initialise()
{ {
database = new SQLiteManager("localhost", "db", "user", "password", "false"); database = new SQLiteManager("localhost", "db", "user", "password", "false");
} }
@ -55,7 +55,7 @@ namespace OpenSim.Framework.Data.SQLite
/// <summary> /// <summary>
/// Shuts down the grid interface /// Shuts down the grid interface
/// </summary> /// </summary>
public void Close() override public void Close()
{ {
database.Close(); database.Close();
} }
@ -64,7 +64,7 @@ namespace OpenSim.Framework.Data.SQLite
/// Returns the name of this grid interface /// Returns the name of this grid interface
/// </summary> /// </summary>
/// <returns>A string containing the grid interface</returns> /// <returns>A string containing the grid interface</returns>
public string getName() override public string getName()
{ {
return "SQLite OpenGridData"; return "SQLite OpenGridData";
} }
@ -73,7 +73,7 @@ namespace OpenSim.Framework.Data.SQLite
/// Returns the version of this grid interface /// Returns the version of this grid interface
/// </summary> /// </summary>
/// <returns>A string containing the version</returns> /// <returns>A string containing the version</returns>
public string getVersion() override public string getVersion()
{ {
return "0.1"; return "0.1";
} }
@ -86,7 +86,7 @@ namespace OpenSim.Framework.Data.SQLite
/// <param name="c">maximum X coordinate</param> /// <param name="c">maximum X coordinate</param>
/// <param name="d">maximum Y coordinate</param> /// <param name="d">maximum Y coordinate</param>
/// <returns>An array of region profiles</returns> /// <returns>An array of region profiles</returns>
public RegionProfileData[] GetProfilesInRange(uint a, uint b, uint c, uint d) override public RegionProfileData[] GetProfilesInRange(uint a, uint b, uint c, uint d)
{ {
return null; return null;
} }
@ -96,7 +96,7 @@ namespace OpenSim.Framework.Data.SQLite
/// </summary> /// </summary>
/// <param name="handle">Region location handle</param> /// <param name="handle">Region location handle</param>
/// <returns>Sim profile</returns> /// <returns>Sim profile</returns>
public RegionProfileData GetProfileByHandle(ulong handle) override public RegionProfileData GetProfileByHandle(ulong handle)
{ {
Dictionary<string, string> param = new Dictionary<string, string>(); Dictionary<string, string> param = new Dictionary<string, string>();
param["handle"] = handle.ToString(); param["handle"] = handle.ToString();
@ -116,7 +116,7 @@ namespace OpenSim.Framework.Data.SQLite
/// </summary> /// </summary>
/// <param name="regionName">The region name search query</param> /// <param name="regionName">The region name search query</param>
/// <returns>The sim profile</returns> /// <returns>The sim profile</returns>
public RegionProfileData GetProfileByString(string regionName) override public RegionProfileData GetProfileByString(string regionName)
{ {
if (regionName.Length > 2) if (regionName.Length > 2)
{ {
@ -145,7 +145,7 @@ namespace OpenSim.Framework.Data.SQLite
/// </summary> /// </summary>
/// <param name="uuid">The region UUID</param> /// <param name="uuid">The region UUID</param>
/// <returns>The sim profile</returns> /// <returns>The sim profile</returns>
public RegionProfileData GetProfileByLLUUID(LLUUID uuid) override public RegionProfileData GetProfileByLLUUID(LLUUID uuid)
{ {
Dictionary<string, string> param = new Dictionary<string, string>(); Dictionary<string, string> param = new Dictionary<string, string>();
param["uuid"] = uuid.ToString(); param["uuid"] = uuid.ToString();
@ -175,7 +175,7 @@ namespace OpenSim.Framework.Data.SQLite
/// </summary> /// </summary>
/// <param name="profile">The profile to add</param> /// <param name="profile">The profile to add</param>
/// <returns>A dataresponse enum indicating success</returns> /// <returns>A dataresponse enum indicating success</returns>
public DataResponse AddProfile(RegionProfileData profile) override public DataResponse AddProfile(RegionProfileData profile)
{ {
if (database.insertRow(profile)) if (database.insertRow(profile))
{ {
@ -194,7 +194,7 @@ namespace OpenSim.Framework.Data.SQLite
/// <param name="handle">The attempted regionHandle of the challenger</param> /// <param name="handle">The attempted regionHandle of the challenger</param>
/// <param name="authkey">The secret</param> /// <param name="authkey">The secret</param>
/// <returns>Whether the secret and regionhandle match the database entry for UUID</returns> /// <returns>Whether the secret and regionhandle match the database entry for UUID</returns>
public bool AuthenticateSim(LLUUID uuid, ulong handle, string authkey) override public bool AuthenticateSim(LLUUID uuid, ulong handle, string authkey)
{ {
bool throwHissyFit = false; // Should be true by 1.0 bool throwHissyFit = false; // Should be true by 1.0
@ -226,7 +226,7 @@ namespace OpenSim.Framework.Data.SQLite
return false; return false;
} }
public ReservationData GetReservationAtPoint(uint x, uint y) override public ReservationData GetReservationAtPoint(uint x, uint y)
{ {
return null; return null;
} }

View File

@ -1,10 +1,22 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Text; using System.Text;
using libsecondlife;
namespace OpenSim.Framework.Data namespace OpenSim.Framework.Data
{ {
public abstract class GridDataBase public abstract class GridDataBase : IGridData
{ {
public abstract RegionProfileData GetProfileByHandle(ulong regionHandle);
public abstract RegionProfileData GetProfileByLLUUID(LLUUID UUID);
public abstract RegionProfileData GetProfileByString(string regionName);
public abstract RegionProfileData[] GetProfilesInRange(uint Xmin, uint Ymin, uint Xmax, uint Ymax);
public abstract bool AuthenticateSim(LLUUID UUID, ulong regionHandle, string simrecvkey);
public abstract void Initialise();
public abstract void Close();
public abstract string getName();
public abstract string getVersion();
public abstract DataResponse AddProfile(RegionProfileData profile);
public abstract ReservationData GetReservationAtPoint(uint x, uint y);
} }
} }