Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Add private structures and functions + wrapping for Surf links and workstations
[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 SG_link_t __SG_link_create(const char *name, void *surf_link, void *data) {
8   xbt_assert0(surf_link != NULL, "surf_link is NULL !");
9   SG_link_data_t sgdata = xbt_new0(s_SG_link_data_t, 1); /* link private data */
10   sgdata->surf_link = surf_link;
11
12   SG_link_t link = xbt_new0(s_SG_link_t, 1);
13   link->name = xbt_strdup(name);
14   link->data = data;
15   link->sgdata = sgdata;
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* SG_link_get_data(SG_link_t link) {
27   xbt_assert0(link, "Invalid parameter");
28   return link->data;
29 }
30
31 /* Sets the user data of a link. The data can be NULL.
32  */
33 void SG_link_set_data(SG_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* SG_link_get_name(SG_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 SG_link_get_capacity(SG_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 SG_link_get_current_bandwidth(SG_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 SG_link_get_current_latency(SG_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 __SG_link_destroy(SG_link_t link) {
76   xbt_assert0(link, "Invalid parameter");
77
78   if (link->name)
79     xbt_free(link->name);
80
81   xbt_free(link);
82 }