* Use the commander name to register module commanders instead of providing the information twice
parent
65448cd02d
commit
9a666bda02
|
@ -29,6 +29,11 @@ namespace OpenSim.Region.Environment.Interfaces
|
||||||
{
|
{
|
||||||
public interface ICommander
|
public interface ICommander
|
||||||
{
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// The name of this commander
|
||||||
|
/// </summary>
|
||||||
|
string Name { get; }
|
||||||
|
|
||||||
void ProcessConsoleCommand(string function, string[] args);
|
void ProcessConsoleCommand(string function, string[] args);
|
||||||
void RegisterCommand(string commandName, ICommand command);
|
void RegisterCommand(string commandName, ICommand command);
|
||||||
void Run(string function, object[] args);
|
void Run(string function, object[] args);
|
||||||
|
|
|
@ -41,18 +41,36 @@ namespace OpenSim.Region.Environment.Modules.Framework.InterfaceCommander
|
||||||
public class Commander : ICommander
|
public class Commander : ICommander
|
||||||
{
|
{
|
||||||
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
|
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
|
||||||
private Dictionary<string, ICommand> m_commands = new Dictionary<string, ICommand>();
|
|
||||||
|
/// <value>
|
||||||
|
/// Used in runtime class generation
|
||||||
|
/// </summary>
|
||||||
|
private string m_generatedApiClassName;
|
||||||
|
|
||||||
|
public string Name
|
||||||
|
{
|
||||||
|
get { return m_name; }
|
||||||
|
}
|
||||||
private string m_name;
|
private string m_name;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Constructor
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="name"></param>
|
||||||
public Commander(string name)
|
public Commander(string name)
|
||||||
{
|
{
|
||||||
m_name = name;
|
m_name = name;
|
||||||
|
m_generatedApiClassName = m_name;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <value>
|
||||||
|
/// Commands that this commander knows about
|
||||||
|
/// </value>
|
||||||
public Dictionary<string, ICommand> Commands
|
public Dictionary<string, ICommand> Commands
|
||||||
{
|
{
|
||||||
get { return m_commands; }
|
get { return m_commands; }
|
||||||
}
|
}
|
||||||
|
private Dictionary<string, ICommand> m_commands = new Dictionary<string, ICommand>();
|
||||||
|
|
||||||
#region ICommander Members
|
#region ICommander Members
|
||||||
|
|
||||||
|
@ -67,7 +85,7 @@ namespace OpenSim.Region.Environment.Modules.Framework.InterfaceCommander
|
||||||
/// <returns>Returns C# source code to create a binding</returns>
|
/// <returns>Returns C# source code to create a binding</returns>
|
||||||
public string GenerateRuntimeAPI()
|
public string GenerateRuntimeAPI()
|
||||||
{
|
{
|
||||||
string classSrc = "\n\tpublic class " + m_name + " {\n";
|
string classSrc = "\n\tpublic class " + m_generatedApiClassName + " {\n";
|
||||||
foreach (ICommand com in m_commands.Values)
|
foreach (ICommand com in m_commands.Values)
|
||||||
{
|
{
|
||||||
classSrc += "\tpublic void " + EscapeRuntimeAPICommand(com.Name) + "( ";
|
classSrc += "\tpublic void " + EscapeRuntimeAPICommand(com.Name) + "( ";
|
||||||
|
|
|
@ -62,7 +62,7 @@ namespace OpenSim.Region.Environment.Modules.Framework.InterfaceCommander
|
||||||
m_commander.RegisterCommand("hello", testCommand);
|
m_commander.RegisterCommand("hello", testCommand);
|
||||||
|
|
||||||
// Register me
|
// Register me
|
||||||
m_scene.RegisterModuleCommander("commandertest", m_commander);
|
m_scene.RegisterModuleCommander(m_commander);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Close()
|
public void Close()
|
||||||
|
|
|
@ -237,7 +237,7 @@ namespace OpenSim.Region.Environment.Modules.World.Permissions
|
||||||
debugCommand.AddArgument("enable_debug_perms", "true to enable debugging to console all perms", "Boolean");
|
debugCommand.AddArgument("enable_debug_perms", "true to enable debugging to console all perms", "Boolean");
|
||||||
|
|
||||||
m_commander.RegisterCommand("debug", debugCommand);
|
m_commander.RegisterCommand("debug", debugCommand);
|
||||||
m_scene.RegisterModuleCommander("CommanderPermissions", m_commander);
|
m_scene.RegisterModuleCommander(m_commander);
|
||||||
|
|
||||||
m_scene.EventManager.OnPluginConsole += new EventManager.OnPluginConsoleDelegate(EventManager_OnPluginConsole);
|
m_scene.EventManager.OnPluginConsole += new EventManager.OnPluginConsoleDelegate(EventManager_OnPluginConsole);
|
||||||
}
|
}
|
||||||
|
|
|
@ -47,7 +47,7 @@ namespace OpenSim.Region.Environment.Modules.World.Serialiser
|
||||||
|
|
||||||
public void Initialise(Scene scene, IConfigSource source)
|
public void Initialise(Scene scene, IConfigSource source)
|
||||||
{
|
{
|
||||||
scene.RegisterModuleCommander("Export", m_commander);
|
scene.RegisterModuleCommander(m_commander);
|
||||||
scene.EventManager.OnPluginConsole += EventManager_OnPluginConsole;
|
scene.EventManager.OnPluginConsole += EventManager_OnPluginConsole;
|
||||||
scene.RegisterModuleInterface<IRegionSerialiserModule>(this);
|
scene.RegisterModuleInterface<IRegionSerialiserModule>(this);
|
||||||
|
|
||||||
|
|
|
@ -993,7 +993,7 @@ namespace OpenSim.Region.Environment.Modules.World.Terrain
|
||||||
m_commander.RegisterCommand("flip", flipCommand);
|
m_commander.RegisterCommand("flip", flipCommand);
|
||||||
|
|
||||||
// Add this to our scene so scripts can call these functions
|
// Add this to our scene so scripts can call these functions
|
||||||
m_scene.RegisterModuleCommander("Terrain", m_commander);
|
m_scene.RegisterModuleCommander(m_commander);
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
|
@ -278,11 +278,11 @@ namespace OpenSim.Region.Environment.Scenes
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void RegisterModuleCommander(string name, ICommander commander)
|
public void RegisterModuleCommander(ICommander commander)
|
||||||
{
|
{
|
||||||
lock (m_moduleCommanders)
|
lock (m_moduleCommanders)
|
||||||
{
|
{
|
||||||
m_moduleCommanders.Add(name, commander);
|
m_moduleCommanders.Add(commander.Name, commander);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue