namespace kernel {
namespace routing {
-NetZoneImpl::NetZoneImpl(NetZoneImpl* father, const std::string& name, resource::NetworkModel* network_model)
- : piface_(this), father_(father), name_(name), network_model_(network_model)
+NetZoneImpl::NetZoneImpl(const std::string& name) : piface_(this), name_(name)
{
xbt_assert(nullptr == s4u::Engine::get_instance()->netpoint_by_name_or_null(get_name()),
"Refusing to create a second NetZone called '%s'.", get_cname());
-
- netpoint_ = new NetPoint(name_, NetPoint::Type::NetZone, father_);
- cpu_model_vm_ = static_cast<simgrid::kernel::resource::CpuModel*>(
- simgrid::kernel::EngineImpl::get_instance()->get_default_model(simgrid::kernel::resource::Model::Type::CPU_VM));
- cpu_model_pm_ = static_cast<simgrid::kernel::resource::CpuModel*>(
- simgrid::kernel::EngineImpl::get_instance()->get_default_model(simgrid::kernel::resource::Model::Type::CPU_PM));
- disk_model_ = static_cast<simgrid::kernel::resource::DiskModel*>(
- simgrid::kernel::EngineImpl::get_instance()->get_default_model(simgrid::kernel::resource::Model::Type::DISK));
- host_model_ = static_cast<simgrid::surf::HostModel*>(
- simgrid::kernel::EngineImpl::get_instance()->get_default_model(simgrid::kernel::resource::Model::Type::HOST));
+ netpoint_ = new NetPoint(name_, NetPoint::Type::NetZone);
XBT_DEBUG("NetZone '%s' created with the id '%u'", get_cname(), netpoint_->id());
}
s4u::Engine::get_instance()->netpoint_unregister(netpoint_);
}
+void NetZoneImpl::add_child(NetZoneImpl* new_zone)
+{
+ xbt_assert(not sealed_, "Cannot add a new child to the sealed zone %s", get_cname(););
+ children_.push_back(new_zone);
+}
+
/** @brief Returns the list of the hosts found in this NetZone (not recursively)
*
* Only the hosts that are directly contained in this NetZone are retrieved,
hierarchy_ = RoutingMode::base;
auto* res = new s4u::Host(name);
- res->set_netpoint(new NetPoint(name, NetPoint::Type::Host, this));
+ res->set_netpoint((new NetPoint(name, NetPoint::Type::Host))->set_englobing_zone(this));
cpu_model_pm_->create_cpu(res, speed_per_pstate)->set_core_count(core_amount)->seal();
NetZoneImpl* current = src->get_englobing_zone();
while (current != nullptr) {
path_src.push_back(current);
- current = current->get_father();
+ current = current->get_parent();
}
std::vector<NetZoneImpl*> path_dst;
current = dst->get_englobing_zone();
while (current != nullptr) {
path_dst.push_back(current);
- current = current->get_father();
+ current = current->get_parent();
}
/* (3) find the common father.
NetZoneImpl* current = src->get_englobing_zone();
while (current != nullptr) {
path_src.push_back(current);
- current = current->father_;
+ current = current->parent_;
}
std::vector<NetZoneImpl*> path_dst;
current = dst->get_englobing_zone();
while (current != nullptr) {
path_dst.push_back(current);
- current = current->father_;
+ current = current->parent_;
}
/* (2) find the common father */
if (route.gw_dst != dst)
get_global_route(route.gw_dst, dst, links, latency);
}
+
+void NetZoneImpl::seal()
+{
+ do_seal(); // derived class' specific sealing procedure
+ sealed_ = true;
+}
+
+void NetZoneImpl::set_parent(NetZoneImpl* parent)
+{
+ xbt_assert(sealed_ == false, "Impossible to set parent to an already sealed NetZone(%s)", this->get_cname());
+ parent_ = parent;
+ netpoint_->set_englobing_zone(parent_);
+}
+
+void NetZoneImpl::set_network_model(std::shared_ptr<resource::NetworkModel> netmodel)
+{
+ xbt_assert(sealed_ == false, "Impossible to set network model to an already sealed NetZone(%s)", this->get_cname());
+ network_model_ = std::move(netmodel);
+}
+
+void NetZoneImpl::set_cpu_vm_model(std::shared_ptr<resource::CpuModel> cpu_model)
+{
+ xbt_assert(sealed_ == false, "Impossible to set CPU model to an already sealed NetZone(%s)", this->get_cname());
+ cpu_model_vm_ = std::move(cpu_model);
+}
+
+void NetZoneImpl::set_cpu_pm_model(std::shared_ptr<resource::CpuModel> cpu_model)
+{
+ xbt_assert(sealed_ == false, "Impossible to set CPU model to an already sealed NetZone(%s)", this->get_cname());
+ cpu_model_pm_ = std::move(cpu_model);
+}
+
+void NetZoneImpl::set_disk_model(std::shared_ptr<resource::DiskModel> disk_model)
+{
+ xbt_assert(sealed_ == false, "Impossible to set disk model to an already sealed NetZone(%s)", this->get_cname());
+ disk_model_ = std::move(disk_model);
+}
+
+void NetZoneImpl::set_host_model(std::shared_ptr<surf::HostModel> host_model)
+{
+ xbt_assert(sealed_ == false, "Impossible to set host model to an already sealed NetZone(%s)", this->get_cname());
+ host_model_ = std::move(host_model);
+}
+
} // namespace routing
} // namespace kernel
} // namespace simgrid