mirror of
https://github.com/opensim/opensim.git
synced 2026-08-10 19:36:07 +08:00
Added IRegistryCore and RegistryCore to OpenSim.Framework.
Added a ApplicationRegistry to OpenSimBase. Changed LoadRegionsPlugin so it registers itself to that application registry. Added a event to LoadRegionsPlugin, that is triggered when it creates a new scene ,although maybe this event should actually be in opensimBase incase other plugins are creating regions (like the RemoteAdminPlugin).
This commit is contained in:
13
OpenSim/Framework/IRegistryCore.cs
Normal file
13
OpenSim/Framework/IRegistryCore.cs
Normal file
@@ -0,0 +1,13 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace OpenSim.Framework
|
||||
{
|
||||
public interface IRegistryCore
|
||||
{
|
||||
T Get<T>();
|
||||
void RegisterInterface<T>(T iface);
|
||||
bool TryGet<T>(out T iface);
|
||||
}
|
||||
}
|
||||
44
OpenSim/Framework/RegistryCore.cs
Normal file
44
OpenSim/Framework/RegistryCore.cs
Normal file
@@ -0,0 +1,44 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace OpenSim.Framework
|
||||
{
|
||||
public class RegistryCore
|
||||
{
|
||||
protected Dictionary<Type, object> m_moduleInterfaces = new Dictionary<Type, object>();
|
||||
|
||||
/// <summary>
|
||||
/// Register an Module interface.
|
||||
/// </summary>
|
||||
/// <typeparam name="T"></typeparam>
|
||||
/// <param name="iface"></param>
|
||||
public void RegisterInterface<T>(T iface)
|
||||
{
|
||||
lock (m_moduleInterfaces)
|
||||
{
|
||||
if (!m_moduleInterfaces.ContainsKey(typeof(T)))
|
||||
{
|
||||
m_moduleInterfaces.Add(typeof(T), iface);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public bool TryGet<T>(out T iface)
|
||||
{
|
||||
if (m_moduleInterfaces.ContainsKey(typeof(T)))
|
||||
{
|
||||
iface = (T)m_moduleInterfaces[typeof(T)];
|
||||
return true;
|
||||
}
|
||||
iface = default(T);
|
||||
return false;
|
||||
}
|
||||
|
||||
public T Get<T>()
|
||||
{
|
||||
return (T)m_moduleInterfaces[typeof(T)];
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user