Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Rename functions in simgrid_lua.c
[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
16 // Workstation list
17 static VALUE rb_SD_workstation_list(VALUE class)
18 {
19
20   int i, nb;
21   nb = SD_workstation_get_number();
22   VALUE workstation_list = rb_ary_new2(nb);
23   for (i = 0; i < nb; i++) {
24     VALUE wrk = Qnil;
25     wrk =
26         Data_Wrap_Struct(class, 0, SD_workstation_free,
27                          SD_workstation_get_list()[i]);
28     rb_ary_push(workstation_list, wrk);
29
30   }
31   return workstation_list;
32 }
33
34 // Workstation number
35 static VALUE rb_SD_workstation_number(VALUE class)
36 {
37   int nb = SD_workstation_get_number();
38   return INT2NUM(nb);
39 }
40
41 // Workstation name
42 static VALUE rb_SD_workstation_name(VALUE class, VALUE workstation)
43 {
44   SD_workstation_t wk;
45   Data_Get_Struct(workstation, SD_workstation_t, wk);
46   return rb_str_new2(SD_workstation_get_name(wk));
47
48 }