- namespace kernel {
- namespace routing {
-
- class BypassRoute {
- public:
- explicit BypassRoute(NetCard* gwSrc, NetCard* gwDst) : gw_src(gwSrc), gw_dst(gwDst) {}
- const NetCard* gw_src;
- const NetCard* gw_dst;
- std::vector<Link*> links;
- };
-
- AsImpl::AsImpl(As* father, const char* name) : As(father, name)
- {
- xbt_assert(nullptr == xbt_lib_get_or_null(as_router_lib, name, ROUTING_ASR_LEVEL),
- "Refusing to create a second AS called '%s'.", name);
-
- netcard_ = new NetCard(name, NetCard::Type::As, static_cast<AsImpl*>(father));
- xbt_lib_set(as_router_lib, name, ROUTING_ASR_LEVEL, static_cast<void*>(netcard_));
- XBT_DEBUG("AS '%s' created with the id '%d'", name, netcard_->id());
- }
- AsImpl::~AsImpl()
- {
- for (auto& kv : bypassRoutes_)
- delete kv.second;
+namespace kernel {
+namespace routing {
+
+class BypassRoute {
+public:
+ explicit BypassRoute(NetPoint* gwSrc, NetPoint* gwDst) : gw_src(gwSrc), gw_dst(gwDst) {}
+ NetPoint* gw_src;
+ NetPoint* gw_dst;
+ std::vector<resource::LinkImpl*> links;
+};
+
+NetZoneImpl::NetZoneImpl(NetZone* father, std::string name) : NetZone(father, name)
+{
+ xbt_assert(nullptr == simgrid::s4u::Engine::get_instance()->netpoint_by_name_or_null(name.c_str()),
+ "Refusing to create a second NetZone called '%s'.", name.c_str());
+
+ netpoint_ = new NetPoint(name, NetPoint::Type::NetZone, static_cast<NetZoneImpl*>(father));
+ XBT_DEBUG("NetZone '%s' created with the id '%u'", name.c_str(), netpoint_->id());
+}
+
+NetZoneImpl::~NetZoneImpl()
+{
+ for (auto const& kv : bypass_routes_)
+ delete kv.second;
+
+ simgrid::s4u::Engine::get_instance()->netpoint_unregister(netpoint_);
+}
+
+simgrid::s4u::Host* NetZoneImpl::create_host(const char* name, std::vector<double>* speedPerPstate, int coreAmount,
+ std::map<std::string, std::string>* props)
+{
+ simgrid::s4u::Host* res = new simgrid::s4u::Host(name);
+
+ if (hierarchy_ == RoutingMode::unset)
+ hierarchy_ = RoutingMode::base;
+
+ res->pimpl_netpoint = new NetPoint(name, NetPoint::Type::Host, this);
+
+ surf_cpu_model_pm->create_cpu(res, speedPerPstate, coreAmount);
+
+ if (props != nullptr)
+ for (auto const& kv : *props)
+ res->set_property(kv.first, kv.second);
+
+ simgrid::s4u::Host::on_creation(*res); // notify the signal
+
+ return res;
+}
+
+void NetZoneImpl::add_bypass_route(NetPoint* src, NetPoint* dst, NetPoint* gw_src, NetPoint* gw_dst,
+ std::vector<resource::LinkImpl*>& link_list, bool symmetrical)
+{
+ /* Argument validity checks */
+ if (gw_dst) {
+ XBT_DEBUG("Load bypassNetzoneRoute from %s@%s to %s@%s", src->get_cname(), gw_src->get_cname(), dst->get_cname(),
+ gw_dst->get_cname());
+ xbt_assert(not link_list.empty(), "Bypass route between %s@%s and %s@%s cannot be empty.", src->get_cname(),
+ gw_src->get_cname(), dst->get_cname(), gw_dst->get_cname());
+ xbt_assert(bypass_routes_.find({src, dst}) == bypass_routes_.end(),
+ "The bypass route between %s@%s and %s@%s already exists.", src->get_cname(), gw_src->get_cname(),
+ dst->get_cname(), gw_dst->get_cname());
+ } else {
+ XBT_DEBUG("Load bypassRoute from %s to %s", src->get_cname(), dst->get_cname());
+ xbt_assert(not link_list.empty(), "Bypass route between %s and %s cannot be empty.", src->get_cname(),
+ dst->get_cname());
+ xbt_assert(bypass_routes_.find({src, dst}) == bypass_routes_.end(),
+ "The bypass route between %s and %s already exists.", src->get_cname(), dst->get_cname());