X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/3f17e7a2d9e727cf8ba2da354280f3afd329c8a6..f1b22d20918d4ccd703690a19e476429cfa124f3:/src/simdag/sd_link.c diff --git a/src/simdag/sd_link.c b/src/simdag/sd_link.c index 0edd95e860..6ee5e6f788 100644 --- a/src/simdag/sd_link.c +++ b/src/simdag/sd_link.c @@ -1,97 +1,32 @@ +/* Copyright (c) 2006-2015. The SimGrid Team. + * All rights reserved. */ + +/* This program is free software; you can redistribute it and/or modify it + * under the terms of the license (GNU LGPL) which comes with this package. */ + #include "private.h" -#include "simdag/simdag.h" +#include "simgrid/simdag.h" #include "xbt/dict.h" #include "xbt/sysdep.h" #include "surf/surf.h" - -/* Creates a link and registers it in SD. - */ -SD_link_t __SD_link_create(void *surf_link, void *data) { - SD_CHECK_INIT_DONE(); - xbt_assert0(surf_link != NULL, "surf_link is NULL !"); - - - SD_link_t link = xbt_new0(s_SD_link_t, 1); - link->surf_link = surf_link; - link->data = data; /* user data */ - - const char *name = SD_link_get_name(link); - xbt_dict_set(sd_global->links, name, link, __SD_link_destroy); /* add the link to the dictionary */ - - return link; -} - -/** - * \brief Returns the user data of a link - * - * \param link a link - * \return the user data associated with this link (can be \c NULL) - * \see SD_link_set_data() - */ -void* SD_link_get_data(SD_link_t link) { - SD_CHECK_INIT_DONE(); - xbt_assert0(link != NULL, "Invalid parameter"); - return link->data; -} +#include "simgrid/link.h" /** - * \brief Sets the user data of a link + * \brief Returns the link list * - * The new data can be \c NULL. The old data should have been freed first - * if it was not \c NULL. + * Use SD_link_get_number() to know the array size. * - * \param link a link - * \param data the new data you want to associate with this link - * \see SD_link_get_data() + * \return an array of \ref SD_link_t containing all links + * \see SD_link_get_number() */ -void SD_link_set_data(SD_link_t link, void *data) { - SD_CHECK_INIT_DONE(); - xbt_assert0(link != NULL, "Invalid parameter"); - link->data = data; -} +const SD_link_t *SD_link_get_list(void) +{ + if (sd_global->link_list == NULL) /* this is the first time the function is called */ + sd_global->link_list = sg_link_list(); -/** - * \brief Returns the name of a link - * - * \param link a link - * \return the name of this link (cannot be \c NULL) - */ -const char* SD_link_get_name(SD_link_t link) { - SD_CHECK_INIT_DONE(); - xbt_assert0(link != NULL, "Invalid parameter"); - return surf_workstation_resource->extension_public->get_link_name(link->surf_link); + return sd_global->link_list; } -/** - * \brief Returns the current bandwidth of a link - * - * \param link a link - * \return the current bandwidth of this link, in Flops - */ -double SD_link_get_current_bandwidth(SD_link_t link) { - SD_CHECK_INIT_DONE(); - xbt_assert0(link != NULL, "Invalid parameter"); - return surf_workstation_resource->extension_public->get_link_bandwidth(link->surf_link); -} -/** - * \brief Returns the current latency of a link - * - * \param link a link - * \return the current latency of this link, in seconds - */ -double SD_link_get_current_latency(SD_link_t link) { - SD_CHECK_INIT_DONE(); - xbt_assert0(link != NULL, "Invalid parameter"); - return surf_workstation_resource->extension_public->get_link_latency(link->surf_link); -} -/* Destroys a link. - */ -void __SD_link_destroy(void *link) { - SD_CHECK_INIT_DONE(); - xbt_assert0(link != NULL, "Invalid parameter"); - /* link->surf_link is freed by surf_exit and link->data is freed by the user */ - xbt_free(link); -}