From: Martin Quinson Date: Tue, 14 Feb 2017 00:45:05 +0000 (+0100) Subject: complete a bit the C wrapper of s4u::Host X-Git-Tag: v3_15~394 X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/commitdiff_plain/11a84d2a50a791eb36fc12576335cf6158109c80 complete a bit the C wrapper of s4u::Host --- diff --git a/include/simgrid/host.h b/include/simgrid/host.h index e1d6c26daf..4fd737bff0 100644 --- a/include/simgrid/host.h +++ b/include/simgrid/host.h @@ -51,8 +51,10 @@ XBT_PUBLIC(int) sg_host_get_nb_pstates(sg_host_t host); XBT_PUBLIC(int) sg_host_get_pstate(sg_host_t host); XBT_PUBLIC(void) sg_host_set_pstate(sg_host_t host,int pstate); XBT_PUBLIC(xbt_dict_t) sg_host_get_properties(sg_host_t host); -XBT_PUBLIC(const char *) sg_host_get_property_value(sg_host_t host, - const char *name); +XBT_PUBLIC(const char*) sg_host_get_property_value(sg_host_t host, const char* name); +XBT_PUBLIC(void) sg_host_route(sg_host_t from, sg_host_t to, xbt_dynar_t links); +XBT_PUBLIC(double) sg_host_route_latency(sg_host_t from, sg_host_t to); +XBT_PUBLIC(double) sg_host_route_bandwidth(sg_host_t from, sg_host_t to); XBT_PUBLIC(void) sg_host_dump(sg_host_t ws); SG_END_DECL() diff --git a/src/simgrid/host.cpp b/src/simgrid/host.cpp index 9808aa6f69..30988adcff 100644 --- a/src/simgrid/host.cpp +++ b/src/simgrid/host.cpp @@ -189,6 +189,48 @@ const char *sg_host_get_property_value(sg_host_t host, const char *name) { return (const char*) xbt_dict_get_or_null(sg_host_get_properties(host), name); } +/** + * \brief Find a route between two hosts + * + * \param from where from + * \param to where to + * \param links [OUT] where to store the list of links (must exist, cannot be nullptr). + */ +void sg_host_route(sg_host_t from, sg_host_t to, xbt_dynar_t links) +{ + std::vector vlinks; + from->routeTo(to, &vlinks, nullptr); + for (auto link : vlinks) + xbt_dynar_push(links, &link); +} +/** + * \brief Find the latency of the route between two hosts + * + * \param from where from + * \param to where to + */ +double sg_host_route_latency(sg_host_t from, sg_host_t to) +{ + std::vector vlinks; + double res = 0; + from->routeTo(to, &vlinks, &res); + return res; +} +/** + * \brief Find the bandwitdh of the route between two hosts + * + * \param from where from + * \param to where to + */ +double sg_host_route_bandwidth(sg_host_t from, sg_host_t to) +{ + std::vector vlinks; + from->routeTo(to, &vlinks, nullptr); + double res = 0; + for (auto link : vlinks) + res += link->bandwidth(); + return res; +} /** @brief Displays debugging information about a host */ void sg_host_dump(sg_host_t host)