Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
simplification: inline a virtual function that is never derivated
[simgrid.git] / src / surf / sg_platf.cpp
index 632ae08..7693e7c 100644 (file)
@@ -19,6 +19,7 @@
 #include "src/include/simgrid/sg_config.h"
 #include "src/surf/xml/platf_private.hpp"
 
+#include "src/surf/HostImpl.hpp"
 #include "src/surf/cpu_interface.hpp"
 #include "src/surf/network_interface.hpp"
 #include "surf/surf_routing.h" // FIXME: brain dead public header
@@ -72,11 +73,9 @@ void sg_platf_exit() {
   surf_parse_lex_destroy();
 }
 
-/** @brief Add an "host" to the current AS */
+/** @brief Add an host to the current AS */
 void sg_platf_new_host(sg_platf_host_cbarg_t host)
 {
-  xbt_assert(sg_host_by_name(host->id) == nullptr, "Refusing to create a second host named '%s'.", host->id);
-
   simgrid::kernel::routing::AsImpl* current_routing = routing_get_current();
   if (current_routing->hierarchy_ == simgrid::kernel::routing::AsImpl::RoutingMode::unset)
     current_routing->hierarchy_ = simgrid::kernel::routing::AsImpl::RoutingMode::base;
@@ -84,14 +83,9 @@ void sg_platf_new_host(sg_platf_host_cbarg_t host)
   simgrid::kernel::routing::NetCard *netcard =
       new simgrid::kernel::routing::NetCardImpl(host->id, simgrid::kernel::routing::NetCard::Type::Host, current_routing);
 
-  sg_host_t h = simgrid::s4u::Host::by_name_or_create(host->id);
+  simgrid::s4u::Host* h = new simgrid::s4u::Host(host->id);
   h->pimpl_netcard = netcard;
 
-  if(mount_list) {
-    xbt_lib_set(storage_lib, host->id, ROUTING_STORAGE_HOST_LEVEL, (void *) mount_list);
-    mount_list = nullptr;
-  }
-
   if (host->coord && strcmp(host->coord, "")) {
     unsigned int cursor;
     char*str;
@@ -116,7 +110,12 @@ void sg_platf_new_host(sg_platf_host_cbarg_t host)
     cpu->setStateTrace(host->state_trace);
   if (host->speed_trace)
     cpu->setSpeedTrace(host->speed_trace);
-  surf_host_model->createHost(host->id, netcard, cpu)->attach(h);
+
+  simgrid::surf::HostImpl* hi = new simgrid::surf::HostImpl(surf_host_model, host->id, mount_list, cpu);
+  hi->attach(h);
+  xbt_lib_set(storage_lib, host->id, ROUTING_STORAGE_HOST_LEVEL, (void*)mount_list);
+
+  mount_list = nullptr;
 
   if (host->properties) {
     xbt_dict_cursor_t cursor=nullptr;