Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
27eefcefe2bf6d444ad1bc9a344966ba55fa7cc4
[simgrid.git] / src / bindings / ruby / rb_msg_host.c
1 #include "rb_msg_host.h"
2
3 // Free Method
4 static void host_free(m_host_t ht) {
5   //Nothing to do !!?
6 }
7
8
9 // New Method : return a Host
10 static VALUE host_get_by_name(VALUE class, VALUE name)
11 {
12   
13   m_host_t host = MSG_get_host_by_name(RSTRING(name)->ptr);
14   if(!host)
15     
16     rb_raise(rb_eRuntimeError,"MSG_get_host_by_name() failled");
17   
18   return Data_Wrap_Struct(class, 0, host_free, host);
19
20 }
21
22
23 //Get Name
24
25 static VALUE host_name(VALUE class,VALUE host)
26 {
27   
28   // Wrap Ruby Value to m_host_t struct
29   
30   m_host_t ht;
31   Data_Get_Struct(host, m_host_t, ht);
32   return rb_str_new2(MSG_host_get_name(ht));
33    
34 }
35
36 // Get Number
37 static VALUE host_number(VALUE class)
38 {
39  
40   return MSG_get_host_number();
41   
42 }
43
44 // Host Speed ( Double )
45 static VALUE host_speed(VALUE class,VALUE host)
46 {
47   m_host_t ht ;
48   Data_Get_Struct(host,m_host_t,ht);
49   return MSG_get_host_speed(ht);
50   
51 }
52
53
54 // Host Set Data
55 static void host_set_data(VALUE class,VALUE host,VALUE data)
56 {
57   //...
58 }
59
60 // Host Get Data
61 static VALUE host_get_data(VALUE class,VALUE host)
62 {
63   //...
64   return Qnil;
65 }
66
67
68
69
70 // Host is Avail
71 static VALUE host_is_avail(VALUE class,VALUE host)
72 {
73  
74   m_host_t ht;
75   Data_Get_Struct(host,m_host_t,ht);
76   if (!ht)
77   {
78     rb_raise(rb_eRuntimeError,"Host not Bound");
79     return Qnil;
80   }
81   
82   if(MSG_host_is_avail(ht))
83     return Qtrue;
84   
85   return Qfalse;
86 }