Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Remove unnecessary calls to c_str().
authorArnaud Giersch <arnaud.giersch@univ-fcomte.fr>
Tue, 12 Mar 2019 09:42:03 +0000 (10:42 +0100)
committerArnaud Giersch <arnaud.giersch@univ-fcomte.fr>
Tue, 12 Mar 2019 15:41:48 +0000 (16:41 +0100)
src/kernel/routing/VivaldiZone.cpp
src/surf/network_ns3.cpp
src/surf/sg_platf.cpp
src/surf/storage_n11.cpp
src/surf/xml/surfxml_parseplatf.cpp
src/surf/xml/surfxml_sax_cb.cpp
teshsuite/s4u/comm-pt2pt/comm-pt2pt.cpp

index 48a2ac9..5eb0694 100644 (file)
@@ -85,8 +85,8 @@ void VivaldiZone::get_local_route(NetPoint* src, NetPoint* dst, RouteCreationArg
   if (src->is_netzone()) {
     std::string srcName = "router_" + src->get_name();
     std::string dstName = "router_" + dst->get_name();
   if (src->is_netzone()) {
     std::string srcName = "router_" + src->get_name();
     std::string dstName = "router_" + dst->get_name();
-    route->gw_src       = simgrid::s4u::Engine::get_instance()->netpoint_by_name_or_null(srcName.c_str());
-    route->gw_dst       = simgrid::s4u::Engine::get_instance()->netpoint_by_name_or_null(dstName.c_str());
+    route->gw_src       = simgrid::s4u::Engine::get_instance()->netpoint_by_name_or_null(srcName);
+    route->gw_dst       = simgrid::s4u::Engine::get_instance()->netpoint_by_name_or_null(dstName);
   }
 
   /* Retrieve the private links */
   }
 
   /* Retrieve the private links */
index d33067f..0a71792 100644 (file)
@@ -73,7 +73,7 @@ static void clusterCreation_cb(simgrid::kernel::routing::ClusterCreationArgs* cl
 
     // Create private link
     std::string host_id   = cluster->prefix + std::to_string(i) + cluster->suffix;
 
     // Create private link
     std::string host_id   = cluster->prefix + std::to_string(i) + cluster->suffix;
-    NetPointNs3* host_src = sg_host_by_name(host_id.c_str())->pimpl_netpoint->extension<NetPointNs3>();
+    NetPointNs3* host_src = simgrid::s4u::Host::by_name(host_id)->pimpl_netpoint->extension<NetPointNs3>();
     xbt_assert(host_src, "Cannot find a NS3 host of name %s", host_id.c_str());
 
     // Any NS3 route is symmetrical
     xbt_assert(host_src, "Cannot find a NS3 host of name %s", host_id.c_str());
 
     // Any NS3 route is symmetrical
index dc1d5c3..5eac4b4 100644 (file)
@@ -636,7 +636,7 @@ void sg_platf_new_Zone_seal()
 /** @brief Add a link connecting a host to the rest of its AS (which must be cluster or vivaldi) */
 void sg_platf_new_hostlink(simgrid::kernel::routing::HostLinkCreationArgs* hostlink)
 {
 /** @brief Add a link connecting a host to the rest of its AS (which must be cluster or vivaldi) */
 void sg_platf_new_hostlink(simgrid::kernel::routing::HostLinkCreationArgs* hostlink)
 {
-  simgrid::kernel::routing::NetPoint* netpoint = sg_host_by_name(hostlink->id.c_str())->pimpl_netpoint;
+  simgrid::kernel::routing::NetPoint* netpoint = simgrid::s4u::Host::by_name(hostlink->id)->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 a host_link.");
   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 a host_link.");
index 82aa54a..f550883 100644 (file)
@@ -6,6 +6,7 @@
 #include "storage_n11.hpp"
 #include "simgrid/kernel/routing/NetPoint.hpp"
 #include "simgrid/s4u/Engine.hpp"
 #include "storage_n11.hpp"
 #include "simgrid/kernel/routing/NetPoint.hpp"
 #include "simgrid/s4u/Engine.hpp"
+#include "simgrid/s4u/Host.hpp"
 #include "src/kernel/lmm/maxmin.hpp"
 #include "src/surf/xml/platf.hpp"
 #include "surf/surf.hpp"
 #include "src/kernel/lmm/maxmin.hpp"
 #include "src/surf/xml/platf.hpp"
 #include "surf/surf.hpp"
@@ -20,12 +21,13 @@ extern std::map<std::string, simgrid::kernel::resource::StorageType*> storage_ty
 void check_disk_attachment()
 {
   for (auto const& s : simgrid::s4u::Engine::get_instance()->get_all_storages()) {
 void check_disk_attachment()
 {
   for (auto const& s : simgrid::s4u::Engine::get_instance()->get_all_storages()) {
-    simgrid::kernel::routing::NetPoint* host_elm = sg_netpoint_by_name_or_null(s->get_impl()->getHost().c_str());
+    simgrid::kernel::routing::NetPoint* host_elm =
+        simgrid::s4u::Engine::get_instance()->netpoint_by_name_or_null(s->get_impl()->getHost());
     if (not host_elm)
       surf_parse_error(std::string("Unable to attach storage ") + s->get_cname() + ": host " +
     if (not host_elm)
       surf_parse_error(std::string("Unable to attach storage ") + s->get_cname() + ": host " +
-                       s->get_impl()->getHost().c_str() + " does not exist.");
+                       s->get_impl()->getHost() + " does not exist.");
     else
     else
-      s->set_host(sg_host_by_name(s->get_impl()->getHost().c_str()));
+      s->set_host(simgrid::s4u::Host::by_name(s->get_impl()->getHost()));
   }
 }
 
   }
 }
 
index 739247a..8fb038a 100644 (file)
@@ -105,7 +105,7 @@ void parse_platform_file(const std::string& file)
     xbt_assert(traces_set_list.find(elm.first) != traces_set_list.end(), "Trace %s undefined", elm.first.c_str());
     simgrid::kernel::profile::Profile* profile = traces_set_list.at(elm.first);
 
     xbt_assert(traces_set_list.find(elm.first) != traces_set_list.end(), "Trace %s undefined", elm.first.c_str());
     simgrid::kernel::profile::Profile* profile = traces_set_list.at(elm.first);
 
-    simgrid::s4u::Host* host = sg_host_by_name(elm.second.c_str());
+    simgrid::s4u::Host* host = simgrid::s4u::Host::by_name_or_null(elm.second);
     xbt_assert(host, "Host %s undefined", elm.second.c_str());
     simgrid::surf::Cpu* cpu = host->pimpl_cpu;
 
     xbt_assert(host, "Host %s undefined", elm.second.c_str());
     simgrid::surf::Cpu* cpu = host->pimpl_cpu;
 
@@ -116,7 +116,7 @@ void parse_platform_file(const std::string& file)
     xbt_assert(traces_set_list.find(elm.first) != traces_set_list.end(), "Trace %s undefined", elm.first.c_str());
     simgrid::kernel::profile::Profile* profile = traces_set_list.at(elm.first);
 
     xbt_assert(traces_set_list.find(elm.first) != traces_set_list.end(), "Trace %s undefined", elm.first.c_str());
     simgrid::kernel::profile::Profile* profile = traces_set_list.at(elm.first);
 
-    simgrid::s4u::Host* host = sg_host_by_name(elm.second.c_str());
+    simgrid::s4u::Host* host = simgrid::s4u::Host::by_name_or_null(elm.second);
     xbt_assert(host, "Host %s undefined", elm.second.c_str());
     simgrid::surf::Cpu* cpu = host->pimpl_cpu;
 
     xbt_assert(host, "Host %s undefined", elm.second.c_str());
     simgrid::surf::Cpu* cpu = host->pimpl_cpu;
 
@@ -127,7 +127,7 @@ void parse_platform_file(const std::string& file)
     xbt_assert(traces_set_list.find(elm.first) != traces_set_list.end(), "Trace %s undefined", elm.first.c_str());
     simgrid::kernel::profile::Profile* profile = traces_set_list.at(elm.first);
 
     xbt_assert(traces_set_list.find(elm.first) != traces_set_list.end(), "Trace %s undefined", elm.first.c_str());
     simgrid::kernel::profile::Profile* profile = traces_set_list.at(elm.first);
 
-    sg_link_t link = simgrid::s4u::Link::by_name(elm.second.c_str());
+    sg_link_t link = simgrid::s4u::Link::by_name(elm.second);
     xbt_assert(link, "Link %s undefined", elm.second.c_str());
     link->set_state_profile(profile);
   }
     xbt_assert(link, "Link %s undefined", elm.second.c_str());
     link->set_state_profile(profile);
   }
@@ -135,7 +135,7 @@ void parse_platform_file(const std::string& file)
   for (auto const& elm : trace_connect_list_link_bw) {
     xbt_assert(traces_set_list.find(elm.first) != traces_set_list.end(), "Trace %s undefined", elm.first.c_str());
     simgrid::kernel::profile::Profile* profile = traces_set_list.at(elm.first);
   for (auto const& elm : trace_connect_list_link_bw) {
     xbt_assert(traces_set_list.find(elm.first) != traces_set_list.end(), "Trace %s undefined", elm.first.c_str());
     simgrid::kernel::profile::Profile* profile = traces_set_list.at(elm.first);
-    sg_link_t link     = simgrid::s4u::Link::by_name(elm.second.c_str());
+    sg_link_t link                             = simgrid::s4u::Link::by_name(elm.second);
     xbt_assert(link, "Link %s undefined", elm.second.c_str());
     link->set_bandwidth_profile(profile);
   }
     xbt_assert(link, "Link %s undefined", elm.second.c_str());
     link->set_bandwidth_profile(profile);
   }
@@ -143,7 +143,7 @@ void parse_platform_file(const std::string& file)
   for (auto const& elm : trace_connect_list_link_lat) {
     xbt_assert(traces_set_list.find(elm.first) != traces_set_list.end(), "Trace %s undefined", elm.first.c_str());
     simgrid::kernel::profile::Profile* profile = traces_set_list.at(elm.first);
   for (auto const& elm : trace_connect_list_link_lat) {
     xbt_assert(traces_set_list.find(elm.first) != traces_set_list.end(), "Trace %s undefined", elm.first.c_str());
     simgrid::kernel::profile::Profile* profile = traces_set_list.at(elm.first);
-    sg_link_t link     = simgrid::s4u::Link::by_name(elm.second.c_str());
+    sg_link_t link                             = simgrid::s4u::Link::by_name(elm.second);
     xbt_assert(link, "Link %s undefined", elm.second.c_str());
     link->set_latency_profile(profile);
   }
     xbt_assert(link, "Link %s undefined", elm.second.c_str());
     link->set_latency_profile(profile);
   }
index 4465820..26046c6 100644 (file)
@@ -53,7 +53,7 @@ void surf_parse_error(const std::string& msg)
 
 void surf_parse_assert_netpoint(const std::string& hostname, const std::string& pre, const std::string& post)
 {
 
 void surf_parse_assert_netpoint(const std::string& hostname, const std::string& pre, const std::string& post)
 {
-  if (sg_netpoint_by_name_or_null(hostname.c_str()) != nullptr) // found
+  if (simgrid::s4u::Engine::get_instance()->netpoint_by_name_or_null(hostname) != nullptr) // found
     return;
 
   std::string msg = pre + hostname + post + " Existing netpoints: \n";
     return;
 
   std::string msg = pre + hostname + post + " Existing netpoints: \n";
index e26d0f0..bc625c9 100644 (file)
@@ -49,7 +49,7 @@ static void sender(std::vector<std::string> args)
   for (unsigned int test = 1; test <= args[0].size(); test++) {
     simgrid::s4u::this_actor::sleep_until(test * 5 - 5);
     std::string* mboxName         = new std::string("Test #" + std::to_string(test));
   for (unsigned int test = 1; test <= args[0].size(); test++) {
     simgrid::s4u::this_actor::sleep_until(test * 5 - 5);
     std::string* mboxName         = new std::string("Test #" + std::to_string(test));
-    simgrid::s4u::MailboxPtr mbox = simgrid::s4u::Mailbox::by_name(mboxName->c_str());
+    simgrid::s4u::MailboxPtr mbox = simgrid::s4u::Mailbox::by_name(*mboxName);
 
     switch (args[0][test - 1]) {
       case 'r':
 
     switch (args[0][test - 1]) {
       case 'r':
@@ -96,7 +96,7 @@ static void receiver(std::vector<std::string> args)
   for (unsigned int test = 1; test <= args[0].size(); test++) {
     simgrid::s4u::this_actor::sleep_until(test * 5 - 5);
     std::string mboxName          = "Test #" + std::to_string(test);
   for (unsigned int test = 1; test <= args[0].size(); test++) {
     simgrid::s4u::this_actor::sleep_until(test * 5 - 5);
     std::string mboxName          = "Test #" + std::to_string(test);
-    simgrid::s4u::MailboxPtr mbox = simgrid::s4u::Mailbox::by_name(mboxName.c_str());
+    simgrid::s4u::MailboxPtr mbox = simgrid::s4u::Mailbox::by_name(mboxName);
     void* received                = nullptr;
 
     switch (args[0][test - 1]) {
     void* received                = nullptr;
 
     switch (args[0][test - 1]) {