Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
fixing some privacy violation ( no more #include "msg/private.h") in ruby bindings...
[simgrid.git] / src / bindings / ruby / rb_msg_host.c
index 4ac3a82..64f16b4 100644 (file)
@@ -45,17 +45,6 @@ VALUE rb_host_speed(VALUE class,VALUE host) {
   return MSG_get_host_speed(ht);
 }
 
-// Host Set Data
-void rb_host_set_data(VALUE class,VALUE host,VALUE data) {
-  THROW_UNIMPLEMENTED;
-}
-
-// Host Get Data
-VALUE rb_host_get_data(VALUE class,VALUE host) {
-  THROW_UNIMPLEMENTED;
-  return Qnil;
-}
-
 // Host is Avail
 VALUE rb_host_is_avail(VALUE class,VALUE host) {
   m_host_t ht;
@@ -70,3 +59,39 @@ VALUE rb_host_is_avail(VALUE class,VALUE host) {
 
   return Qfalse;
 }
+
+// getHost from process
+VALUE rb_host_process(VALUE class,VALUE ruby_process)
+{
+  
+ m_process_t process = rb_process_to_native(ruby_process);
+  m_host_t host;
+  
+
+  if (!process) {
+    rb_raise(rb_eRuntimeError,"Process Not Bound...while getting Host");
+    return Qnil; // NULL
+  }
+  
+  host = MSG_process_get_host(process);
+  
+  return Data_Wrap_Struct(class, 0, rb_host_free, host); 
+
+}
+
+// get all hosts
+VALUE rb_host_get_all_hosts(VALUE class)
+{
+       int nb,index;
+       m_host_t *hosts;
+       VALUE rb_hosts;
+       nb = MSG_get_host_number();
+       hosts  = MSG_get_host_table();
+    rb_hosts = rb_ary_new2(nb);
+
+    for(index=0 ; index<nb; index++)
+       rb_ary_push(rb_hosts,Data_Wrap_Struct(class, 0, rb_host_free, hosts[index]));
+
+    return rb_hosts;
+}
+