Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Add some patches for delete some warnings with cmake.
[simgrid.git] / buildtools / CPACK / Patch / src / bindings / ruby / rb_msg_host.c
1 /*
2  * $Id$
3  *
4  * Copyright 2010 Martin Quinson, Mehdi Fekari           
5  * All right reserved. 
6  *
7  * This program is free software; you can redistribute 
8  * it and/or modify it under the terms of the license 
9  *(GNU LGPL) which comes with this package. 
10  */
11 #include "rb_msg_host.h"
12
13 // Free Method
14 void host_free(m_host_t ht) {
15   //Nothing to do !!?
16 }
17
18 // New Method : return a Host
19 static VALUE host_get_by_name(VALUE class, VALUE name)
20 {
21   
22   const char * h_name = RSTRING(name)->ptr;
23   m_host_t host = MSG_get_host_by_name(h_name);
24   if(!host)
25     rb_raise(rb_eRuntimeError,"MSG_get_host_by_name() failled");
26   
27   return Data_Wrap_Struct(class,0,host_free,host);
28
29 }
30
31 //Get Name
32 static VALUE host_name(VALUE class,VALUE host)
33 {
34   
35   // Wrap Ruby Value to m_host_t struct
36   m_host_t *ht;
37   Data_Get_Struct(host, m_host_t, ht);
38   return rb_str_new2(MSG_host_get_name(*ht));
39    
40 }
41
42 // Get Number
43 static VALUE host_number(VALUE class)
44 {
45   
46   return INT2NUM(MSG_get_host_number());
47   
48 }
49
50 // Host Speed ( Double )
51 static VALUE host_speed(VALUE class,VALUE host)
52 {
53   m_host_t *ht ;
54   Data_Get_Struct(host,m_host_t,ht);
55   return MSG_get_host_speed(*ht);
56   
57 }
58
59 // Host Set Data
60 static void host_set_data(VALUE class,VALUE host,VALUE data)
61 {
62   //...
63 }
64
65 // Host Get Data
66 static VALUE host_get_data(VALUE class,VALUE host)
67 {
68   //...
69   return Qnil;
70 }
71
72 // Host is Avail
73 static VALUE host_is_avail(VALUE class,VALUE host)
74 {
75  
76   m_host_t *ht;
77   Data_Get_Struct(host,m_host_t,ht);
78   if (!*ht)
79   {
80     rb_raise(rb_eRuntimeError,"Host not Bound");
81     return Qnil;
82   }
83   
84   if(MSG_host_is_avail(*ht))
85     return Qtrue;
86   
87   return Qfalse;
88 }