Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
stringify Host link creation
authorFrederic Suter <frederic.suter@cc.in2p3.fr>
Fri, 11 Aug 2017 09:33:28 +0000 (11:33 +0200)
committerFrederic Suter <frederic.suter@cc.in2p3.fr>
Fri, 11 Aug 2017 09:33:28 +0000 (11:33 +0200)
src/surf/sg_platf.cpp
src/surf/xml/platf_private.hpp
src/surf/xml/surfxml_sax_cb.cpp

index 4801306..1214fd5 100644 (file)
@@ -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<simgrid::kernel::routing::ClusterZone*>(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<simgrid::kernel::routing::ClusterZone*>(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}});
index aedd266..03e3ed1 100644 (file)
@@ -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
index bd7ffc5..53a931d 100644 (file)
@@ -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;