2 #include "simdag/simdag.h"
4 #include "xbt/sysdep.h" /* xbt_new0 */
8 SD_link_t __SD_link_create(void *surf_link, char *name, void *data) {
10 xbt_assert0(surf_link != NULL, "surf_link is NULL !");
11 xbt_assert0(name != NULL, "name 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;
15 sd_data->name = xbt_strdup(name);
17 SD_link_t link = xbt_new0(s_SD_link_t, 1);
18 link->sd_data = sd_data; /* private data */
19 link->data = data; /* user data */
21 /*link->capacity = capacity;*/
22 /* link->current_bandwidth = bandwidth;
23 link->current_latency = latency;*/
25 /*xbt_dynar_push(sd_global->links, link);*/
26 xbt_dict_set(sd_global->links, name, link, __SD_link_destroy); /* add the workstation to the dictionary */
31 /* Returns the user data of a link. The user data can be NULL.
33 void* SD_link_get_data(SD_link_t link) {
35 xbt_assert0(link != NULL, "Invalid parameter");
39 /* 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.
41 void SD_link_set_data(SD_link_t link, void *data) {
43 xbt_assert0(link != NULL, "Invalid parameter");
47 /* Returns the name of a link. The name can be NULL.
49 const char* SD_link_get_name(SD_link_t link) {
51 xbt_assert0(link != NULL, "Invalid parameter");
52 return link->sd_data->name;
54 /* return surf_network_resource->common_public->get_resource_name(link->sd_data->surf_link);*/
57 /* Returns the capacity of a link.
60 double SD_link_get_capacity(SD_link_t link) {
61 xbt_assert0(link, "Invalid parameter");
62 return link->capacity;
65 /* Return the current bandwidth of a link.
67 double SD_link_get_current_bandwidth(SD_link_t link) {
69 xbt_assert0(link != NULL, "Invalid parameter");
70 return surf_workstation_resource->extension_public->get_link_bandwidth(link->sd_data->surf_link);
73 /* Return the current latency of a link.
75 double SD_link_get_current_latency(SD_link_t link) {
77 xbt_assert0(link != NULL, "Invalid parameter");
78 return surf_workstation_resource->extension_public->get_link_latency(link->sd_data->surf_link);
81 /* Destroys a link. The user data (if any) should have been destroyed first.
83 void __SD_link_destroy(void *link) {
85 xbt_assert0(link != NULL, "Invalid parameter");
87 SD_link_data_t sd_data = ((SD_link_t) link)->data;
88 if (sd_data != NULL) {
89 if (sd_data->name != NULL)
90 xbt_free(sd_data->name);