Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
272ceba54240e6ab3c3ef0834a6aacde254873b9
[simgrid.git] / src / simdag / sd_link.c
1 #include "simdag/simdag.h"
2 #include "xbt/sysdep.h" /* xbt_new0 */
3
4 /* Creates a link.
5  */
6 SG_link_t SG_link_create(void *data, const char *name,/* double capacity,*/ double bandwidth, double latency) {
7   /*  xbt_assert0(capacity >= 0, "Invalid parameter");*/ /* or capacity > 0 ? */
8
9   SG_link_t link = xbt_new0(s_SG_link_t, 1);
10
11   link->data = data;
12   link->name = xbt_strdup(name);
13   /*link->capacity = capacity;*/
14   /* link->current_bandwidth = bandwidth;
15      link->current_latency = latency;*/
16
17   return link;
18 }
19
20 /* Returns the user data of a link. The user data can be NULL.
21  */
22 void* SG_link_get_data(SG_link_t link) {
23   xbt_assert0(link, "Invalid parameter");
24   return link->data;
25 }
26
27 /* Sets the user data of a link. The data can be NULL.
28  */
29 void SG_link_set_data(SG_link_t link, void *data) {
30   xbt_assert0(link, "Invalid parameter");
31   link->data = data;
32 }
33
34 /* Returns the name of a link. The name can be NULL.
35  */
36 const char* SG_link_get_name(SG_link_t link) {
37   xbt_assert0(link, "Invalid parameter");
38   return link->name;
39 }
40
41 /* Returns the capacity of a link.
42  */
43 /*
44 double SG_link_get_capacity(SG_link_t link) {
45   xbt_assert0(link, "Invalid parameter");
46   return link->capacity;
47 }*/
48
49 /* Return the current bandwidth of a link.
50  */
51 double SG_link_get_current_bandwidth(SG_link_t link) {
52   xbt_assert0(link, "Invalid parameter");
53
54   /* TODO */
55   return 0;
56   /*  return link->current_bandwidth;*/
57 }
58
59 /* Return the current latency of a link.
60  */
61 double SG_link_get_current_latency(SG_link_t link) {
62   xbt_assert0(link, "Invalid parameter");
63
64   /* TODO */
65   return 0;
66   /*  return link->current_latency;*/
67 }
68
69 /* Destroys a link. The user data (if any) should have been destroyed first.
70  */
71 void SG_link_destroy(SG_link_t link) {
72   xbt_assert0(link, "Invalid parameter");
73
74   if (link->name)
75     free(link->name);
76
77   free(link);
78 }