Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
redefinition of task and host ruby classes to adopte an object-oriented approach
[simgrid.git] / src / bindings / ruby / simgrid.rb
index 5c96cdb..3c5eede 100644 (file)
@@ -1,3 +1,5 @@
+# FIXME: add license like in C files
+
 require 'simgrid_ruby'
 require 'thread'
 
@@ -52,31 +54,24 @@ class MSG::Process < Thread
   @@nextProcessId = 0
 
 # Attributes
-  attr_reader :bind, :id ,:name           # Read only
-  attr_accessor :properties, :pargs  # R/W
+  attr_reader :bind, :id, :name, :pargs ,:properties# Read only
   
-
     def initialize(*args)
       super(){
        
-     raise "Bad Number Of arguments to create a Ruby Process (name,args,prop) " if args.size < 3
+     raise "Bad Number Of arguments to create a Ruby Process (name,args,prop) " if args.size < 3
      
     @schedBegin = Semaphore.new(0)
     @schedEnd = Semaphore.new(0)    
-    #@properties = Hash.new()
-    @id = @@nextProcessId
-    @@nextProcessId += 1
+    #@properties = Hash.new() FIXME: get this from the C (yep that makes 4 args to this function)
+    @id = @@nextProcessId++
     @name = args[0]
     @pargs = args[1]
     @properties = args[2]
-    
-     start()
-      
+    start()
       }
-      
     end
     
-    
   # main
   def main(args) 
     # To be overriden by childs
@@ -89,18 +84,18 @@ class MSG::Process < Thread
     # execute the main code of the process     
     MSG::debug("Begin execution")
     main(@pargs)
-    processExit(self) # Exit the Native Process
+    processExit(self) # Exit the Native Process
     @schedEnd.release
   end
     
 
   
-  #Get Bind ( Used > Native to Ruby)
+  # Get Bind
   def getBind()
     return @bind
   end
   
-  #Get Binds (Used > Ruby to Native)
+  # Set Binds
   def setBind(bind)
     @bind = bind
   end
@@ -115,30 +110,105 @@ class MSG::Process < Thread
     @schedEnd.acquire
   end
   
-   #C Simualator Process Equivalent  Management
-  # After Binding Ruby Process to C Process
-  
-#   pause
   def pause()
     processSuspend(self)
   end
   
-#   restart
   def restart()
     processResume(self)
   end
   
-#   isSuspended
   def isSuspended()
     processIsSuspended(self)
   end
   
-#   getHost
   def getHost()
     processGetHost(self)
   end
   
-# The Rest of Methods !!! To be Continued ...
+# The Rest of Methods !!! To be Continued ... FIXME: what's missing?
+end
+
+############################################
+# Task Extend from the native Class RbTask
+############################################
+class MSG::Task < MSG::RbTask
+
+  def initialize(*args)
+     super()
+  end
+  
+  def name
+     super(self)
+  end
+  
+  def compSize
+     super(self)
+  end
+  
+  def send(mailbox)
+    super(mailbox)
+  end
+  
+  def receive(mailbox)
+    super(mailbox)
+  end
+  
+  def source
+    super(self)
+  end
+  
+  def sender
+    super(self)
+  end
+  
+  def listen(t_alias)
+    super(t_alias)
+  end
+  
+  def execute
+    super(self)
+  end
+    
+  def listenFromHost(t_alias,host)
+    super(t_alias,host)
+  end
+    
+end  
+
+############################################
+# Host Extend from the native Class RbHost
+############################################
+class MSG::Host < MSG::RbHost
+
+  def getByName(name)
+    super(name)
+  end
+  
+  def name
+    super(self)
+  end
+  
+  def speed
+    super(self)
+  end
+  
+  def getData
+    super(self)
+  end
+  
+  def setData(data)
+    super(self,data)
+  end
+  
+  def isAvail
+    super(self)
+  end
+  
+  def number
+    super()
+  end
+  
 end
 
 #########################