Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
424ebc34880f7a7f81448fb1d6466126d93c3be2
[simgrid.git] / src / simdag / sd_link.c
1 #include "private.h"
2 #include "simdag/simdag.h"
3 #include "xbt/sysdep.h" /* xbt_new0 */
4
5 /* Creates a link.
6  */
7 SD_link_t __SD_link_create(const char *name, void *surf_link, void *data) {
8   xbt_assert0(surf_link != NULL, "surf_link is NULL !");
9   SD_link_data_t sd_data = xbt_new0(s_SD_link_data_t, 1); /* link private data */
10   sd_data->surf_link = surf_link;
11
12   SD_link_t link = xbt_new0(s_SD_link_t, 1);
13   link->name = xbt_strdup(name);
14   link->data = data;
15   link->sd_data = sd_data;
16
17   /*link->capacity = capacity;*/
18   /* link->current_bandwidth = bandwidth;
19      link->current_latency = latency;*/
20
21   return link;
22 }
23
24 /* Returns the user data of a link. The user data can be NULL.
25  */
26 void* SD_link_get_data(SD_link_t link) {
27   xbt_assert0(link, "Invalid parameter");
28   return link->data;
29 }
30
31 /* Sets the user data of a link. The new data can be NULL. The old data should have been freed first if it was not NULL.
32  */
33 void SD_link_set_data(SD_link_t link, void *data) {
34   xbt_assert0(link, "Invalid parameter");
35   link->data = data;
36 }
37
38 /* Returns the name of a link. The name can be NULL.
39  */
40 const char* SD_link_get_name(SD_link_t link) {
41   xbt_assert0(link, "Invalid parameter");
42   return link->name;
43 }
44
45 /* Returns the capacity of a link.
46  */
47 /*
48 double SD_link_get_capacity(SD_link_t link) {
49   xbt_assert0(link, "Invalid parameter");
50   return link->capacity;
51 }*/
52
53 /* Return the current bandwidth of a link.
54  */
55 double SD_link_get_current_bandwidth(SD_link_t link) {
56   xbt_assert0(link, "Invalid parameter");
57
58   /* TODO */
59   return 0;
60   /*  return link->current_bandwidth;*/
61 }
62
63 /* Return the current latency of a link.
64  */
65 double SD_link_get_current_latency(SD_link_t link) {
66   xbt_assert0(link, "Invalid parameter");
67
68   /* TODO */
69   return 0;
70   /*  return link->current_latency;*/
71 }
72
73 /* Destroys a link. The user data (if any) should have been destroyed first.
74  */
75 void __SD_link_destroy(SD_link_t link) {
76   xbt_assert0(link, "Invalid parameter");
77
78   if (link->sd_data != NULL)
79     xbt_free(link->sd_data);
80   
81   if (link->name != NULL)
82     xbt_free(link->name);
83
84   xbt_free(link);
85 }