Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Adjust add_route to accept route between netzones
[simgrid.git] / src / kernel / routing / NetZoneImpl.cpp
index 775009a..c1ebb3e 100644 (file)
@@ -109,6 +109,8 @@ NetZoneImpl::~NetZoneImpl()
 void NetZoneImpl::add_child(NetZoneImpl* new_zone)
 {
   xbt_assert(not sealed_, "Cannot add a new child to the sealed zone %s", get_cname());
+  /* set the father behavior */
+  hierarchy_ = RoutingMode::recursive;
   children_.push_back(new_zone);
 }
 
@@ -138,11 +140,14 @@ int NetZoneImpl::get_host_count() const
   return count;
 }
 
-s4u::Disk* NetZoneImpl::create_disk(const std::string& name, double read_bandwidth, double write_bandwidth)
+s4u::Host* NetZoneImpl::create_host(const std::string& name, const std::vector<double>& speed_per_pstate)
 {
-  auto* l = disk_model_->create_disk(name, read_bandwidth, write_bandwidth);
+  auto* res = (new surf::HostImpl(name))->get_iface();
+  res->set_netpoint((new NetPoint(name, NetPoint::Type::Host))->set_englobing_zone(this));
 
-  return l->get_iface();
+  cpu_model_pm_->create_cpu(res, speed_per_pstate);
+
+  return res;
 }
 
 s4u::Link* NetZoneImpl::create_link(const std::string& name, const std::vector<double>& bandwidths)
@@ -150,24 +155,20 @@ s4u::Link* NetZoneImpl::create_link(const std::string& name, const std::vector<d
   return network_model_->create_link(name, bandwidths)->get_iface();
 }
 
-s4u::Link* NetZoneImpl::create_wifi_link(const std::string& name, const std::vector<double>& bandwidths)
+s4u::Disk* NetZoneImpl::create_disk(const std::string& name, double read_bandwidth, double write_bandwidth)
 {
-  return network_model_->create_wifi_link(name, bandwidths)->get_iface();
+  auto* l = disk_model_->create_disk(name, read_bandwidth, write_bandwidth);
+
+  return l->get_iface();
 }
 
-s4u::Host* NetZoneImpl::create_host(const std::string& name, const std::vector<double>& speed_per_pstate)
+NetPoint* NetZoneImpl::create_router(const std::string& name)
 {
-  if (hierarchy_ == RoutingMode::unset)
-    hierarchy_ = RoutingMode::base;
-
-  auto* res = (new surf::HostImpl(name))->get_iface();
-  res->set_netpoint((new NetPoint(name, NetPoint::Type::Host))->set_englobing_zone(this));
-
-  cpu_model_pm_->create_cpu(res, speed_per_pstate);
+  xbt_assert(nullptr == s4u::Engine::get_instance()->netpoint_by_name_or_null(name),
+             "Refusing to create a router named '%s': this name already describes a node.", name.c_str());
 
-  return res;
+  return (new NetPoint(name, NetPoint::Type::Router))->set_englobing_zone(this);
 }
-
 int NetZoneImpl::add_component(NetPoint* elm)
 {
   vertices_.push_back(elm);
@@ -476,7 +477,7 @@ void NetZoneImpl::seal()
   for (auto* host : get_all_hosts()) {
     host->seal();
   }
-  for (auto* sub_net : *get_children()) {
+  for (auto* sub_net : get_children()) {
     sub_net->seal();
   }
   sealed_ = true;