From: Frederic Suter Date: Fri, 11 Aug 2017 09:33:28 +0000 (+0200) Subject: stringify Host link creation X-Git-Tag: v3_17~214 X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/commitdiff_plain/c27325f7854de16164de674d7428d6487c7501db stringify Host link creation --- diff --git a/src/surf/sg_platf.cpp b/src/surf/sg_platf.cpp index 48013068ba..1214fd5589 100644 --- a/src/surf/sg_platf.cpp +++ b/src/surf/sg_platf.cpp @@ -333,13 +333,10 @@ void sg_platf_new_cabinet(CabinetCreationArgs* cabinet) link.id = "link_" + hostname; sg_platf_new_link(&link); - s_sg_platf_host_link_cbarg_t host_link; - memset(&host_link, 0, sizeof(host_link)); - std::string tmp_link_up = std::string("link_") + hostname + "_UP"; - std::string tmp_link_down = std::string("link_") + hostname + "_DOWN"; - host_link.id = hostname.c_str(); - host_link.link_up = tmp_link_up.c_str(); - host_link.link_down = tmp_link_down.c_str(); + HostLinkCreationArgs host_link; + host_link.id = hostname; + host_link.link_up = std::string("link_") + hostname + "_UP"; + host_link.link_down = std::string("link_") + hostname + "_DOWN"; sg_platf_new_hostlink(&host_link); } delete cabinet->radicals; @@ -664,23 +661,23 @@ void sg_platf_new_Zone_seal() } /** @brief Add a link connecting an host to the rest of its AS (which must be cluster or vivaldi) */ -void sg_platf_new_hostlink(sg_platf_host_link_cbarg_t hostlink) +void sg_platf_new_hostlink(HostLinkCreationArgs* hostlink) { - simgrid::kernel::routing::NetPoint* netpoint = sg_host_by_name(hostlink->id)->pimpl_netpoint; - xbt_assert(netpoint, "Host '%s' not found!", hostlink->id); + simgrid::kernel::routing::NetPoint* netpoint = sg_host_by_name(hostlink->id.c_str())->pimpl_netpoint; + xbt_assert(netpoint, "Host '%s' not found!", hostlink->id.c_str()); xbt_assert(dynamic_cast(current_routing), "Only hosts from Cluster and Vivaldi ASes can get an host_link."); simgrid::surf::LinkImpl* linkUp = simgrid::surf::LinkImpl::byName(hostlink->link_up); simgrid::surf::LinkImpl* linkDown = simgrid::surf::LinkImpl::byName(hostlink->link_down); - xbt_assert(linkUp, "Link '%s' not found!", hostlink->link_up); - xbt_assert(linkDown, "Link '%s' not found!", hostlink->link_down); + xbt_assert(linkUp, "Link '%s' not found!", hostlink->link_up.c_str()); + xbt_assert(linkDown, "Link '%s' not found!", hostlink->link_down.c_str()); auto as_cluster = static_cast(current_routing); if (as_cluster->privateLinks_.find(netpoint->id()) != as_cluster->privateLinks_.end()) - surf_parse_error(std::string("Host_link for '") + hostlink->id + "' is already defined!"); + surf_parse_error(std::string("Host_link for '") + hostlink->id.c_str() + "' is already defined!"); XBT_DEBUG("Push Host_link for host '%s' to position %u", netpoint->cname(), netpoint->id()); as_cluster->privateLinks_.insert({netpoint->id(), {linkUp, linkDown}}); diff --git a/src/surf/xml/platf_private.hpp b/src/surf/xml/platf_private.hpp index aedd266489..03e3ed1f93 100644 --- a/src/surf/xml/platf_private.hpp +++ b/src/surf/xml/platf_private.hpp @@ -53,12 +53,12 @@ typedef struct { } s_sg_platf_host_cbarg_t; typedef s_sg_platf_host_cbarg_t* sg_platf_host_cbarg_t; -typedef struct { - const char* id; - const char* link_up; - const char* link_down; -} s_sg_platf_host_link_cbarg_t; -typedef s_sg_platf_host_link_cbarg_t* sg_platf_host_link_cbarg_t; +class HostLinkCreationArgs { +public: + std::string id; + std::string link_up; + std::string link_down; +}; class LinkCreationArgs { public: @@ -205,7 +205,7 @@ XBT_PUBLIC(simgrid::s4u::NetZone*) sg_platf_new_Zone_begin(ZoneCreationArgs* zon XBT_PUBLIC(void) sg_platf_new_Zone_seal(); // That Zone is fully described XBT_PUBLIC(void) sg_platf_new_host(sg_platf_host_cbarg_t host); // Add a host to the current Zone -XBT_PUBLIC(void) sg_platf_new_hostlink(sg_platf_host_link_cbarg_t h); // Add a host_link to the current Zone +XBT_PUBLIC(void) sg_platf_new_hostlink(HostLinkCreationArgs* h); // Add a host_link to the current Zone XBT_PUBLIC(void) sg_platf_new_link(LinkCreationArgs* link); // Add a link to the current Zone XBT_PUBLIC(void) sg_platf_new_peer(PeerCreationArgs* peer); // Add a peer to the current Zone XBT_PUBLIC(void) sg_platf_new_cluster(sg_platf_cluster_cbarg_t clust); // Add a cluster to the current Zone diff --git a/src/surf/xml/surfxml_sax_cb.cpp b/src/surf/xml/surfxml_sax_cb.cpp index bd7ffc5d36..53a931d54d 100644 --- a/src/surf/xml/surfxml_sax_cb.cpp +++ b/src/surf/xml/surfxml_sax_cb.cpp @@ -542,8 +542,7 @@ void ETag_surfxml_host() { void STag_surfxml_host___link(){ XBT_DEBUG("Create a Host_link for %s",A_surfxml_host___link_id); - s_sg_platf_host_link_cbarg_t host_link; - memset(&host_link,0,sizeof(host_link)); + HostLinkCreationArgs host_link; host_link.id = A_surfxml_host___link_id; host_link.link_up = A_surfxml_host___link_up;