Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
c786087b3438c6497747f5b274493e458ea1fc9b
[simgrid.git] / src / simdag / sd_link.c
1 /* Copyright (c) 2006-2014. 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 "private.h"
8 #include "simgrid/simdag.h"
9 #include "xbt/dict.h"
10 #include "xbt/sysdep.h"
11 #include "surf/surf.h"
12 #include "simgrid/link.h"
13
14 /**
15  * \brief Returns the link list
16  *
17  * Use SD_link_get_number() to know the array size.
18  *
19  * \return an array of \ref SD_link_t containing all links
20  * \see SD_link_get_number()
21  */
22 const SD_link_t *SD_link_get_list(void)
23 {
24
25   xbt_lib_cursor_t cursor;
26   char *key;
27   void **data;
28   int i;
29
30   if (sd_global->link_list == NULL) {   /* this is the first time the function is called */
31     sd_global->link_list = xbt_new(SD_link_t, xbt_lib_length(link_lib));
32
33     i = 0;
34     xbt_lib_foreach(link_lib, cursor, key, data) {
35         sd_global->link_list[i++] = (SD_link_t) data[SURF_LINK_LEVEL];
36     }
37   }
38   return sd_global->link_list;
39 }
40
41 /**
42  * \brief Returns the number of links
43  *
44  * \return the number of existing links
45  * \see SD_link_get_list()
46  */
47 int SD_link_get_number(void)
48 {
49   return xbt_lib_length(link_lib);
50 }
51
52
53
54