Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Missing LOG 9 and LOG10 when XBT_LOG_MAYDAY is defined
[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 double SG_link_get_capacity(SG_link_t link) {
44   xbt_assert0(link, "Invalid parameter");
45   return link->capacity;
46 }
47
48 /* Return the current bandwidth of a link.
49  */
50 double SG_link_get_current_bandwidth(SG_link_t link) {
51   xbt_assert0(link, "Invalid parameter");
52   return link->current_bandwidth;
53 }
54
55 /* Return the current latency of a link.
56  */
57 double SG_link_get_current_latency(SG_link_t link) {
58   xbt_assert0(link, "Invalid parameter");
59   return link->current_latency;
60 }
61
62 /* Destroys a link. The user data (if any) should have been destroyed first.
63  */
64 void SG_link_destroy(SG_link_t link) {
65   xbt_assert0(link, "Invalid parameter");
66
67   if (link->name)
68     free(link->name);
69
70   free(link);
71 }