diff options
author | Christian Pointner <equinox@spreadspace.org> | 2010-11-13 13:54:52 +0000 |
---|---|---|
committer | Christian Pointner <equinox@spreadspace.org> | 2010-11-13 13:54:52 +0000 |
commit | dd5159158dc81e07dd242c1ca6429f100fd49d00 (patch) | |
tree | ebc575b3f51d3626d516fdaa4a2cf33c6d89b769 | |
parent | fixed module_list cleanup (diff) |
changed module_type to module_class
git-svn-id: https://svn.spreadspace.org/gcsd/trunk@23 ac14a137-c7f1-4531-abe0-07747231d213
-rw-r--r-- | src/defines.lua | 2 | ||||
-rw-r--r-- | src/main_loop.lua | 4 | ||||
-rw-r--r-- | src/module_list.lua | 4 | ||||
-rw-r--r-- | src/modules/debug_shell.lua | 11 | ||||
-rw-r--r-- | src/modules/dummy.lua | 9 |
5 files changed, 18 insertions, 12 deletions
diff --git a/src/defines.lua b/src/defines.lua index 017fb6f..eabc742 100644 --- a/src/defines.lua +++ b/src/defines.lua @@ -35,7 +35,7 @@ local defines = {} defines.OK = 0 defines.KILL_CLIENT = 1 defines.KILL_MODULE = 2 -defines.KILL_MODULE_TYPE = 3 +defines.KILL_MODULE_CLASS = 3 defines.KILL_DAEMON = 4 return defines
\ No newline at end of file diff --git a/src/main_loop.lua b/src/main_loop.lua index 28681df..5540dee 100644 --- a/src/main_loop.lua +++ b/src/main_loop.lua @@ -88,8 +88,8 @@ function main_loop(opt) if(ret == defines.KILL_DAEMON) then return_value = 2 break - elseif(ret == defines.KILL_MODULE_TYPE) then - module_list:unregister_by_type(reader.client_instance.module_instance.type) + elseif(ret == defines.KILL_MODULE_CLASS) then + module_list:unregister_by_class(reader.client_instance.module_instance.class) elseif(ret == defines.KILL_MODULE) then module_list:unregister(reader.client_instance.module_instance) elseif(ret == defines.KILL_CLIENT) then diff --git a/src/module_list.lua b/src/module_list.lua index 0ad0d35..7c1feae 100644 --- a/src/module_list.lua +++ b/src/module_list.lua @@ -68,11 +68,11 @@ function module_list:unregister(module) end end -function module_list:unregister_by_type(type) +function module_list:unregister_by_class(class) local free_list = {} for i, m in ipairs(self.modules) do - if(m.type == type) then + if(m.class == class) then table.insert(free_list, 1, i) end end diff --git a/src/modules/debug_shell.lua b/src/modules/debug_shell.lua index a84a793..04d94df 100644 --- a/src/modules/debug_shell.lua +++ b/src/modules/debug_shell.lua @@ -33,15 +33,18 @@ local socket = require("socket") local defines = require("defines") +-- debug shell module class local debug_shell = {} -debug_shell.properties = { input=true, output=false, max_instances=-1, module_type_name="debug_shell" } +debug_shell.properties = { input=true, output=false, max_instances=-1, name="debug_shell" } debug_shell.next_id = 0 + +-- create new instance of debug shell module class function debug_shell:new(config) local inst = {} - inst.type = self.properties.module_type_name + inst.class = self.properties.name inst.config = config if(config.name == nil or config.name == "") then - inst.name = self.properties.module_type_name .. self.next_id + inst.name = self.properties.name .. self.next_id self.next_id = self.next_id + 1 else inst.name = config.name @@ -220,7 +223,7 @@ function debug_shell:exec_cmd(socket) elseif(cmd == 'disableall') then if(sep and sep ~= "") then socket.out_buffer = socket.out_buffer .. "unknown command\n" end log.printf(log.NOTICE, "debug shell: disabling all debug shell instances and close all connections") - ret = defines.KILL_MODULE_TYPE + ret = defines.KILL_MODULE_CLASS elseif(cmd == 'terminate') then if(sep and sep ~= "") then socket.out_buffer = socket.out_buffer .. "unknown command\n" end log.printf(log.NOTICE, "debug shell: terminate command received") diff --git a/src/modules/dummy.lua b/src/modules/dummy.lua index ea1679d..04bea15 100644 --- a/src/modules/dummy.lua +++ b/src/modules/dummy.lua @@ -30,15 +30,18 @@ -- along with gcsd. If not, see <http://www.gnu.org/licenses/>. -- +-- dummy module class local dummy = {} -dummy.properties = { input=true, output=true, max_instances=-1, module_type_name="dummy" } +dummy.properties = { input=true, output=true, max_instances=-1, name="dummy" } dummy.next_id = 0 + +-- create new instance of dummy module class function dummy:new(config) local inst = {} - inst.type = self.properties.module_type_name + inst.class = self.properties.name inst.config = config if(config.name == nil or config.name == "") then - inst.name = self.properties.module_type_name .. self.next_id + inst.name = self.properties.name .. self.next_id self.next_id = self.next_id + 1 else inst.name = config.name |