Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
"new ruby host method"
authorcoldpeace <coldpeace@48e7efb5-ca39-0410-a469-dd3cf9ba447f>
Wed, 24 Mar 2010 09:26:39 +0000 (09:26 +0000)
committercoldpeace <coldpeace@48e7efb5-ca39-0410-a469-dd3cf9ba447f>
Wed, 24 Mar 2010 09:26:39 +0000 (09:26 +0000)
git-svn-id: svn+ssh://scm.gforge.inria.fr/svn/simgrid/simgrid/trunk@7344 48e7efb5-ca39-0410-a469-dd3cf9ba447f

src/bindings/ruby/rb_msg_host.c
src/bindings/ruby/simgrid_ruby.c
src/bindings/ruby_bindings.h

index 5320265..138f922 100644 (file)
@@ -76,6 +76,28 @@ VALUE rb_host_process(VALUE class,VALUE ruby_process)
   host = MSG_process_get_host(process);
   
   return Data_Wrap_Struct(class, 0, rb_host_free, host); 
-  
-  
-}
\ No newline at end of file
+
+}
+
+// get all hosts
+VALUE rb_host_get_all_hosts(VALUE class)
+{
+ int index;
+ VALUE hosts_table;
+ VALUE rbHost;
+ m_host_t host;
+
+ int count = xbt_fifo_size(msg_global->host);
+ m_host_t *table = (m_host_t *)xbt_fifo_to_array(msg_global->host);
+ hosts_table = rb_ary_new2(count);
+
+ for (index=0;index<count;index++)
+ {
+        rbHost = Qnil;
+        host = table[index];
+        rbHost = Data_Wrap_Struct(class, 0, rb_host_free, host);
+        rb_ary_push(hosts_table,rbHost);
+ }
+
+ return hosts_table;
+}
index 1840534..6859a41 100644 (file)
@@ -190,4 +190,5 @@ void Init_simgrid_ruby() {
   rb_define_module_function(rb_host,"number",(rb_meth)rb_host_number,0);
   rb_define_module_function(rb_host,"isAvail",(rb_meth)rb_host_is_avail,1);
   rb_define_module_function(rb_host,"getHostProcess",(rb_meth)rb_host_process,1);
-}
\ No newline at end of file
+  rb_define_module_function(rb_host,"all",(rb_meth)rb_host_get_all_hosts,0);
+}
index 48821a9..9444543 100644 (file)
@@ -17,6 +17,7 @@
  */
 
 #include "msg/msg.h"
+#include "msg/private.h"
 #include "msg/datatypes.h"
 
 #include "surf/surfxml_parse.h"
@@ -99,6 +100,7 @@ void  rb_host_set_data(VALUE Class,VALUE host,VALUE data);
 VALUE rb_host_get_data(VALUE Class,VALUE host);
 VALUE rb_host_is_avail(VALUE Class,VALUE host);
 VALUE rb_host_process(VALUE Class,VALUE process);
+VALUE rb_host_get_all_hosts(VALUE Class);
 
 /* Functions related to tasks */
 void rb_task_free(m_task_t tk);