Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
New platform files (just add AS tag)
[simgrid.git] / src / bindings / rubyDag / rb_SD_workstation.c
1 /* Copyright (c) 2010. The SimGrid Team.
2  * All rights reserved.                                                     */
3
4 /* This program is free software; you can redistribute it and/or modify it
5   * under the terms of the license (GNU LGPL) which comes with this package. */
6
7 //#include "ruby_simdag.h"
8 #include "rb_SD_workstation.h"
9
10
11 static void SD_workstation_free(SD_workstation_t wrk)
12 {
13   //NOTHING TO DO
14 }
15 // Workstation list
16 static VALUE rb_SD_workstation_list(VALUE class)
17 {
18  
19   int i,nb;
20   nb = SD_workstation_get_number();
21   VALUE workstation_list = rb_ary_new2(nb);
22   for (i=0;i<nb;i++)
23   {
24    VALUE wrk = Qnil;
25    wrk = Data_Wrap_Struct(class, 0, SD_workstation_free, SD_workstation_get_list()[i]);
26    rb_ary_push(workstation_list,wrk);
27     
28   }
29   return workstation_list;
30 }
31
32 // Workstation number
33 static VALUE rb_SD_workstation_number(VALUE class)
34 {
35   int nb = SD_workstation_get_number();
36   return INT2NUM(nb);
37 }
38
39 // Workstation name
40 static VALUE rb_SD_workstation_name(VALUE class,VALUE workstation)
41 {
42  SD_workstation_t wk;
43  Data_Get_Struct(workstation, SD_workstation_t, wk);
44  return rb_str_new2(SD_workstation_get_name(wk));
45  
46 }