aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorJustin Clarke Casey2009-02-05 19:54:22 +0000
committerJustin Clarke Casey2009-02-05 19:54:22 +0000
commit9a666bda021503591e390facddda617f8b7ead3c (patch)
tree34cf79eb6f7a71003af347a4cbde17f8bad3a118
parent* refactor: Split out module Command class into a separate file (diff)
downloadopensim-SC_OLD-9a666bda021503591e390facddda617f8b7ead3c.zip
opensim-SC_OLD-9a666bda021503591e390facddda617f8b7ead3c.tar.gz
opensim-SC_OLD-9a666bda021503591e390facddda617f8b7ead3c.tar.bz2
opensim-SC_OLD-9a666bda021503591e390facddda617f8b7ead3c.tar.xz
* Use the commander name to register module commanders instead of providing the information twice
-rw-r--r--OpenSim/Region/Environment/Interfaces/ICommander.cs5
-rw-r--r--OpenSim/Region/Environment/Modules/Framework/InterfaceCommander/Commander.cs22
-rw-r--r--OpenSim/Region/Environment/Modules/Framework/InterfaceCommander/CommanderTestModule.cs2
-rw-r--r--OpenSim/Region/Environment/Modules/World/Permissions/PermissionsModule.cs2
-rw-r--r--OpenSim/Region/Environment/Modules/World/Serialiser/SerialiserModule.cs2
-rw-r--r--OpenSim/Region/Environment/Modules/World/Terrain/TerrainModule.cs2
-rw-r--r--OpenSim/Region/Environment/Scenes/SceneBase.cs4
7 files changed, 31 insertions, 8 deletions
diff --git a/OpenSim/Region/Environment/Interfaces/ICommander.cs b/OpenSim/Region/Environment/Interfaces/ICommander.cs
index c4102af..a267115 100644
--- a/OpenSim/Region/Environment/Interfaces/ICommander.cs
+++ b/OpenSim/Region/Environment/Interfaces/ICommander.cs
@@ -29,6 +29,11 @@ namespace OpenSim.Region.Environment.Interfaces
29{ 29{
30 public interface ICommander 30 public interface ICommander
31 { 31 {
32 /// <summary>
33 /// The name of this commander
34 /// </summary>
35 string Name { get; }
36
32 void ProcessConsoleCommand(string function, string[] args); 37 void ProcessConsoleCommand(string function, string[] args);
33 void RegisterCommand(string commandName, ICommand command); 38 void RegisterCommand(string commandName, ICommand command);
34 void Run(string function, object[] args); 39 void Run(string function, object[] args);
diff --git a/OpenSim/Region/Environment/Modules/Framework/InterfaceCommander/Commander.cs b/OpenSim/Region/Environment/Modules/Framework/InterfaceCommander/Commander.cs
index 8b19043..caaa808 100644
--- a/OpenSim/Region/Environment/Modules/Framework/InterfaceCommander/Commander.cs
+++ b/OpenSim/Region/Environment/Modules/Framework/InterfaceCommander/Commander.cs
@@ -41,18 +41,36 @@ namespace OpenSim.Region.Environment.Modules.Framework.InterfaceCommander
41 public class Commander : ICommander 41 public class Commander : ICommander
42 { 42 {
43 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 43 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
44 private Dictionary<string, ICommand> m_commands = new Dictionary<string, ICommand>(); 44
45 /// <value>
46 /// Used in runtime class generation
47 /// </summary>
48 private string m_generatedApiClassName;
49
50 public string Name
51 {
52 get { return m_name; }
53 }
45 private string m_name; 54 private string m_name;
46 55
56 /// <summary>
57 /// Constructor
58 /// </summary>
59 /// <param name="name"></param>
47 public Commander(string name) 60 public Commander(string name)
48 { 61 {
49 m_name = name; 62 m_name = name;
63 m_generatedApiClassName = m_name;
50 } 64 }
51 65
66 /// <value>
67 /// Commands that this commander knows about
68 /// </value>
52 public Dictionary<string, ICommand> Commands 69 public Dictionary<string, ICommand> Commands
53 { 70 {
54 get { return m_commands; } 71 get { return m_commands; }
55 } 72 }
73 private Dictionary<string, ICommand> m_commands = new Dictionary<string, ICommand>();
56 74
57 #region ICommander Members 75 #region ICommander Members
58 76
@@ -67,7 +85,7 @@ namespace OpenSim.Region.Environment.Modules.Framework.InterfaceCommander
67 /// <returns>Returns C# source code to create a binding</returns> 85 /// <returns>Returns C# source code to create a binding</returns>
68 public string GenerateRuntimeAPI() 86 public string GenerateRuntimeAPI()
69 { 87 {
70 string classSrc = "\n\tpublic class " + m_name + " {\n"; 88 string classSrc = "\n\tpublic class " + m_generatedApiClassName + " {\n";
71 foreach (ICommand com in m_commands.Values) 89 foreach (ICommand com in m_commands.Values)
72 { 90 {
73 classSrc += "\tpublic void " + EscapeRuntimeAPICommand(com.Name) + "( "; 91 classSrc += "\tpublic void " + EscapeRuntimeAPICommand(com.Name) + "( ";
diff --git a/OpenSim/Region/Environment/Modules/Framework/InterfaceCommander/CommanderTestModule.cs b/OpenSim/Region/Environment/Modules/Framework/InterfaceCommander/CommanderTestModule.cs
index c569240..f4b56b7 100644
--- a/OpenSim/Region/Environment/Modules/Framework/InterfaceCommander/CommanderTestModule.cs
+++ b/OpenSim/Region/Environment/Modules/Framework/InterfaceCommander/CommanderTestModule.cs
@@ -62,7 +62,7 @@ namespace OpenSim.Region.Environment.Modules.Framework.InterfaceCommander
62 m_commander.RegisterCommand("hello", testCommand); 62 m_commander.RegisterCommand("hello", testCommand);
63 63
64 // Register me 64 // Register me
65 m_scene.RegisterModuleCommander("commandertest", m_commander); 65 m_scene.RegisterModuleCommander(m_commander);
66 } 66 }
67 67
68 public void Close() 68 public void Close()
diff --git a/OpenSim/Region/Environment/Modules/World/Permissions/PermissionsModule.cs b/OpenSim/Region/Environment/Modules/World/Permissions/PermissionsModule.cs
index f765cfe..0fac278 100644
--- a/OpenSim/Region/Environment/Modules/World/Permissions/PermissionsModule.cs
+++ b/OpenSim/Region/Environment/Modules/World/Permissions/PermissionsModule.cs
@@ -237,7 +237,7 @@ namespace OpenSim.Region.Environment.Modules.World.Permissions
237 debugCommand.AddArgument("enable_debug_perms", "true to enable debugging to console all perms", "Boolean"); 237 debugCommand.AddArgument("enable_debug_perms", "true to enable debugging to console all perms", "Boolean");
238 238
239 m_commander.RegisterCommand("debug", debugCommand); 239 m_commander.RegisterCommand("debug", debugCommand);
240 m_scene.RegisterModuleCommander("CommanderPermissions", m_commander); 240 m_scene.RegisterModuleCommander(m_commander);
241 241
242 m_scene.EventManager.OnPluginConsole += new EventManager.OnPluginConsoleDelegate(EventManager_OnPluginConsole); 242 m_scene.EventManager.OnPluginConsole += new EventManager.OnPluginConsoleDelegate(EventManager_OnPluginConsole);
243 } 243 }
diff --git a/OpenSim/Region/Environment/Modules/World/Serialiser/SerialiserModule.cs b/OpenSim/Region/Environment/Modules/World/Serialiser/SerialiserModule.cs
index c1af947..885dbae 100644
--- a/OpenSim/Region/Environment/Modules/World/Serialiser/SerialiserModule.cs
+++ b/OpenSim/Region/Environment/Modules/World/Serialiser/SerialiserModule.cs
@@ -47,7 +47,7 @@ namespace OpenSim.Region.Environment.Modules.World.Serialiser
47 47
48 public void Initialise(Scene scene, IConfigSource source) 48 public void Initialise(Scene scene, IConfigSource source)
49 { 49 {
50 scene.RegisterModuleCommander("Export", m_commander); 50 scene.RegisterModuleCommander(m_commander);
51 scene.EventManager.OnPluginConsole += EventManager_OnPluginConsole; 51 scene.EventManager.OnPluginConsole += EventManager_OnPluginConsole;
52 scene.RegisterModuleInterface<IRegionSerialiserModule>(this); 52 scene.RegisterModuleInterface<IRegionSerialiserModule>(this);
53 53
diff --git a/OpenSim/Region/Environment/Modules/World/Terrain/TerrainModule.cs b/OpenSim/Region/Environment/Modules/World/Terrain/TerrainModule.cs
index d56bc8e..cc9b4d2 100644
--- a/OpenSim/Region/Environment/Modules/World/Terrain/TerrainModule.cs
+++ b/OpenSim/Region/Environment/Modules/World/Terrain/TerrainModule.cs
@@ -993,7 +993,7 @@ namespace OpenSim.Region.Environment.Modules.World.Terrain
993 m_commander.RegisterCommand("flip", flipCommand); 993 m_commander.RegisterCommand("flip", flipCommand);
994 994
995 // Add this to our scene so scripts can call these functions 995 // Add this to our scene so scripts can call these functions
996 m_scene.RegisterModuleCommander("Terrain", m_commander); 996 m_scene.RegisterModuleCommander(m_commander);
997 } 997 }
998 998
999 #endregion 999 #endregion
diff --git a/OpenSim/Region/Environment/Scenes/SceneBase.cs b/OpenSim/Region/Environment/Scenes/SceneBase.cs
index 4d6a39a..5e7eae5 100644
--- a/OpenSim/Region/Environment/Scenes/SceneBase.cs
+++ b/OpenSim/Region/Environment/Scenes/SceneBase.cs
@@ -278,11 +278,11 @@ namespace OpenSim.Region.Environment.Scenes
278 } 278 }
279 } 279 }
280 280
281 public void RegisterModuleCommander(string name, ICommander commander) 281 public void RegisterModuleCommander(ICommander commander)
282 { 282 {
283 lock (m_moduleCommanders) 283 lock (m_moduleCommanders)
284 { 284 {
285 m_moduleCommanders.Add(name, commander); 285 m_moduleCommanders.Add(commander.Name, commander);
286 } 286 }
287 } 287 }
288 288