From 139d102a3b2b25b6e9f93eb3047d290a3eac2794 Mon Sep 17 00:00:00 2001 From: Martin Quinson Date: Tue, 23 Mar 2021 01:41:23 +0100 Subject: [PATCH] Forbid to modify a sealed netzone --- include/simgrid/kernel/routing/NetZoneImpl.hpp | 2 +- src/kernel/routing/NetZoneImpl.cpp | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/include/simgrid/kernel/routing/NetZoneImpl.hpp b/include/simgrid/kernel/routing/NetZoneImpl.hpp index 421fa3e0b1..89ddb84a25 100644 --- a/include/simgrid/kernel/routing/NetZoneImpl.hpp +++ b/include/simgrid/kernel/routing/NetZoneImpl.hpp @@ -128,7 +128,7 @@ public: /** @brief Returns the list of direct children (no grand-children). This returns the internal data, no copy. * Don't mess with it.*/ std::vector* get_children() { return &children_; } - void add_child(NetZoneImpl* new_zone) { children_.push_back(new_zone); } + void add_child(NetZoneImpl* new_zone); /** @brief Retrieves the name of that netzone as a C++ string */ const std::string& get_name() const { return name_; } diff --git a/src/kernel/routing/NetZoneImpl.cpp b/src/kernel/routing/NetZoneImpl.cpp index f11c9cddfd..09ff9b9892 100644 --- a/src/kernel/routing/NetZoneImpl.cpp +++ b/src/kernel/routing/NetZoneImpl.cpp @@ -40,6 +40,12 @@ NetZoneImpl::~NetZoneImpl() 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, -- 2.20.1