/* Link private data */
typedef struct SD_link_data {
void *surf_link; /* surf object */
- char *name;
} s_SD_link_data_t;
/* Workstation private data */
typedef struct SD_workstation_data {
void *surf_workstation; /* surf object */
- /* TODO: route */
} s_SD_workstation_data_t;
/* Private functions */
-SD_link_t __SD_link_create(void *surf_link, char *name, void *data);
+SD_link_t __SD_link_create(void *surf_link, void *data);
void __SD_link_destroy(void *link);
SD_workstation_t __SD_workstation_create(void *surf_workstation, void *data);
}
xbt_dict_foreach(network_link_set, cursor, name, surf_link) {
- __SD_link_create(surf_link, name, NULL);
+ __SD_link_create(surf_link, NULL);
}
}
xbt_dict_foreach(sd_global->links, cursor, name, link) {
bandwidth = SD_link_get_current_bandwidth(link);
latency = SD_link_get_current_latency(link);
- printf("Link name: %s, bandwidth: %f, latency; %f\n", name, bandwidth, latency);
+ printf("Link name: %s, bandwidth: %f, latency: %f\n", name, bandwidth, latency);
}
/* test the route between two workstations */
#include "private.h"
#include "simdag/simdag.h"
+#include "xbt/dict.h"
+#include "xbt/sysdep.h"
#include "surf/surf.h"
-#include "xbt/sysdep.h" /* xbt_new0 */
/* Creates a link.
*/
-SD_link_t __SD_link_create(void *surf_link, char *name, void *data) {
+SD_link_t __SD_link_create(void *surf_link, void *data) {
CHECK_INIT_DONE();
xbt_assert0(surf_link != NULL, "surf_link is NULL !");
- xbt_assert0(name != NULL, "name is NULL !");
SD_link_data_t sd_data = xbt_new0(s_SD_link_data_t, 1); /* link private data */
sd_data->surf_link = surf_link;
- sd_data->name = xbt_strdup(name);
SD_link_t link = xbt_new0(s_SD_link_t, 1);
link->sd_data = sd_data; /* private data */
link->data = data; /* user data */
- /*link->capacity = capacity;*/
- /* link->current_bandwidth = bandwidth;
- link->current_latency = latency;*/
-
- /*xbt_dynar_push(sd_global->links, link);*/
+ const char *name = SD_link_get_name(link);
xbt_dict_set(sd_global->links, name, link, __SD_link_destroy); /* add the workstation to the dictionary */
return link;
link->data = data;
}
-/* Returns the name of a link. The name can be NULL.
+/* Returns the name of a link. The name cannot be NULL.
*/
const char* SD_link_get_name(SD_link_t link) {
CHECK_INIT_DONE();
xbt_assert0(link != NULL, "Invalid parameter");
- return link->sd_data->name;
-
- /* return surf_network_resource->common_public->get_resource_name(link->sd_data->surf_link);*/
+ return surf_workstation_resource->extension_public->get_link_name(link->sd_data->surf_link);
}
/* Returns the capacity of a link.
SD_link_data_t sd_data = ((SD_link_t) link)->data;
if (sd_data != NULL) {
- if (sd_data->name != NULL)
- xbt_free(sd_data->name);
-
xbt_free(sd_data);
}