Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
further simplifications to ruby: kill useless ProcessFactory (should to the same...
authormquinson <mquinson@48e7efb5-ca39-0410-a469-dd3cf9ba447f>
Tue, 2 Mar 2010 01:20:04 +0000 (01:20 +0000)
committermquinson <mquinson@48e7efb5-ca39-0410-a469-dd3cf9ba447f>
Tue, 2 Mar 2010 01:20:04 +0000 (01:20 +0000)
git-svn-id: svn+ssh://scm.gforge.inria.fr/svn/simgrid/simgrid/trunk@7159 48e7efb5-ca39-0410-a469-dd3cf9ba447f

src/bindings/ruby/MasterSlave.rb
src/bindings/ruby/simgrid.rb

index aafa5ed..0156cc9 100644 (file)
@@ -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")
index 9d0b847..c8788e5 100644 (file)
@@ -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