2 #include "simdag/simdag.h"
4 #include "xbt/sysdep.h"
9 SD_link_t __SD_link_create(void *surf_link, void *data) {
11 xbt_assert0(surf_link != NULL, "surf_link is NULL !");
13 SD_link_data_t sd_data = xbt_new0(s_SD_link_data_t, 1); /* link private data */
14 sd_data->surf_link = surf_link;
16 SD_link_t link = xbt_new0(s_SD_link_t, 1);
17 link->sd_data = sd_data; /* private data */
18 link->data = data; /* user data */
20 const char *name = SD_link_get_name(link);
21 xbt_dict_set(sd_global->links, name, link, __SD_link_destroy); /* add the workstation to the dictionary */
26 /* Returns the user data of a link. The user data can be NULL.
28 void* SD_link_get_data(SD_link_t link) {
30 xbt_assert0(link != NULL, "Invalid parameter");
34 /* 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.
36 void SD_link_set_data(SD_link_t link, void *data) {
38 xbt_assert0(link != NULL, "Invalid parameter");
42 /* Returns the name of a link. The name cannot be NULL.
44 const char* SD_link_get_name(SD_link_t link) {
46 xbt_assert0(link != NULL, "Invalid parameter");
47 return surf_workstation_resource->extension_public->get_link_name(link->sd_data->surf_link);
50 /* Returns the capacity of a link.
53 double SD_link_get_capacity(SD_link_t link) {
54 xbt_assert0(link, "Invalid parameter");
55 return link->capacity;
58 /* Return the current bandwidth of a link.
60 double SD_link_get_current_bandwidth(SD_link_t link) {
62 xbt_assert0(link != NULL, "Invalid parameter");
63 return surf_workstation_resource->extension_public->get_link_bandwidth(link->sd_data->surf_link);
66 /* Return the current latency of a link.
68 double SD_link_get_current_latency(SD_link_t link) {
70 xbt_assert0(link != NULL, "Invalid parameter");
71 return surf_workstation_resource->extension_public->get_link_latency(link->sd_data->surf_link);
74 /* Destroys a link. The user data (if any) should have been destroyed first.
76 void __SD_link_destroy(void *link) {
78 xbt_assert0(link != NULL, "Invalid parameter");
80 SD_link_data_t sd_data = ((SD_link_t) link)->data;
81 if (sd_data != NULL) {