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 !");
14 SD_link_t link = xbt_new0(s_SD_link_t, 1);
15 link->surf_link = surf_link;
16 link->data = data; /* user data */
18 const char *name = SD_link_get_name(link);
19 xbt_dict_set(sd_global->links, name, link, __SD_link_destroy); /* add the workstation to the dictionary */
24 /* Returns the user data of a link. The user data can be NULL.
26 void* SD_link_get_data(SD_link_t link) {
28 xbt_assert0(link != NULL, "Invalid parameter");
32 /* 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.
34 void SD_link_set_data(SD_link_t link, void *data) {
36 xbt_assert0(link != NULL, "Invalid parameter");
40 /* Returns the name of a link. The name cannot be NULL.
42 const char* SD_link_get_name(SD_link_t link) {
44 xbt_assert0(link != NULL, "Invalid parameter");
45 return surf_workstation_resource->extension_public->get_link_name(link->surf_link);
48 /* Returns the capacity of a link.
51 double SD_link_get_capacity(SD_link_t link) {
52 xbt_assert0(link, "Invalid parameter");
53 return link->capacity;
56 /* Return the current bandwidth of a link.
58 double SD_link_get_current_bandwidth(SD_link_t link) {
60 xbt_assert0(link != NULL, "Invalid parameter");
61 return surf_workstation_resource->extension_public->get_link_bandwidth(link->surf_link);
64 /* Return the current latency of a link.
66 double SD_link_get_current_latency(SD_link_t link) {
68 xbt_assert0(link != NULL, "Invalid parameter");
69 return surf_workstation_resource->extension_public->get_link_latency(link->surf_link);
72 /* Destroys a link. The user data (if any) should have been destroyed first.
74 void __SD_link_destroy(void *link) {
76 xbt_assert0(link != NULL, "Invalid parameter");
77 /* link->surf_link is freed by surf_exit and link->data is freed by the user */