From: mquinson Date: Tue, 2 Mar 2010 01:20:04 +0000 (+0000) Subject: further simplifications to ruby: kill useless ProcessFactory (should to the same... X-Git-Tag: SVN~579 X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/commitdiff_plain/ea131c282aef654396f98d3e5d0d6cffdbf6ebab?ds=sidebyside further simplifications to ruby: kill useless ProcessFactory (should to the same to java) git-svn-id: svn+ssh://scm.gforge.inria.fr/svn/simgrid/simgrid/trunk@7159 48e7efb5-ca39-0410-a469-dd3cf9ba447f --- diff --git a/src/bindings/ruby/MasterSlave.rb b/src/bindings/ruby/MasterSlave.rb index aafa5edb0c..0156cc9bfb 100644 --- a/src/bindings/ruby/MasterSlave.rb +++ b/src/bindings/ruby/MasterSlave.rb @@ -9,11 +9,6 @@ include MSG ################################################# class Master < MsgProcess - def initialize2() - super() - end - - # msg_main : that function that will be executed when Running Simulation def msg_main(args) # args is an array containing arguments for function master info("Hello From Master") @@ -57,11 +52,6 @@ end # Class Slave ################################################# class Slave < MsgProcess - - def initialize() - super() - end - # msg_main : that function that will be executed when Running Simulation def msg_main(args) info("Hello From Slave") diff --git a/src/bindings/ruby/simgrid.rb b/src/bindings/ruby/simgrid.rb index 9d0b847898..c8788e5950 100644 --- a/src/bindings/ruby/simgrid.rb +++ b/src/bindings/ruby/simgrid.rb @@ -216,90 +216,43 @@ class MsgProcess < Thread # The Rest of Methods !!! To be Continued ... end -######################################################################## -# Class ProcessFactory -######################################################################## - -class ProcessFactory - -# Attributes - attr_accessor :args, :properties, :hostName, :function -# Initialize - def initialize() - - @args = Array.new - @properties = Hash.new - @hostName = nil - @function = nil - - end - -# setProcessIdentity - def setProcessIdentity(hostName,function) - @hostName = hostName - @function = function - - if !args.empty? - args.clear - end - - if !properties.empty? - properties.clear - end - - end - - def registerProcessArg(arg) - @args.push(arg) - end - -# CreateProcess - def createProcess() - process = rubyNewInstance(@function) - size = @args.size - for i in 0..size-1 - process.pargs.push(@args[i]) - end - process.name = @function - host = Host.getByName(@hostName) - processCreate(process,host) - process.properties = @properties - @properties = Hash.new - - end - -# SetProperty - def setProperty(id,value) - @properties[id] = value - end -end - ######################################################################### # Class ApplicationHandler ######################################################################### class ApplicationHandler - @processFactory - def initialize() - @processFactory = ProcessFactory.new + @hostName = nil + @function = nil end def onBeginProcess(hostName,function) - @processFactory.setProcessIdentity(hostName,function) + @args = Array.new + @properties = Hash.new + + @hostName = hostName + @function = function + debug("onBeginProcess("+hostName+","+function+")") end def onProperty(id,value) - @processFactory.setProperty(id,value) + @properties[id] = value end def onProcessArg(arg) - @processFactory.registerProcessArg(arg) + @args.push(arg) end def onEndProcess() - @processFactory.createProcess() - debug("onEndProcess") + process = rubyNewInstance(@function) + size = @args.size + for i in 0..size-1 + process.pargs.push(@args[i]) + end + process.name = @function + host = Host.getByName(@hostName) + processCreate(process,host) + process.properties = @properties end end