2 * Copyright 2010. The SimGrid Team. All right reserved.
4 * This program is free software; you can redistribute
5 * it and/or modify it under the terms of the license
6 *(GNU LGPL) which comes with this package.
8 #include "bindings/ruby_bindings.h"
11 void rb_host_free(m_host_t ht) {
15 // New Method : return a Host
16 VALUE rb_host_get_by_name(VALUE class, VALUE name) {
18 const char * h_name = RSTRING(name)->ptr;
19 m_host_t host = MSG_get_host_by_name(h_name);
21 rb_raise(rb_eRuntimeError,"MSG_get_host_by_name() failled");
23 return Data_Wrap_Struct(class,0,rb_host_free,host);
28 VALUE rb_host_name(VALUE class,VALUE host) {
30 // Wrap Ruby Value to m_host_t struct
32 Data_Get_Struct(host, s_m_host_t, ht);
33 return rb_str_new2(MSG_host_get_name(ht));
38 VALUE rb_host_number(VALUE class) {
39 return INT2NUM(MSG_get_host_number());
42 // Host Speed ( Double )
43 VALUE rb_host_speed(VALUE class,VALUE host) {
45 Data_Get_Struct(host,s_m_host_t,ht);
46 return MSG_get_host_speed(ht);
50 void rb_host_set_data(VALUE class,VALUE host,VALUE data) {
55 VALUE rb_host_get_data(VALUE class,VALUE host) {
61 VALUE rb_host_is_avail(VALUE class,VALUE host) {
63 Data_Get_Struct(host,s_m_host_t,ht);
65 rb_raise(rb_eRuntimeError,"Host not Bound");
69 if(MSG_host_is_avail(ht))