From: Bruno Donassolo Date: Tue, 6 Apr 2021 08:27:02 +0000 (+0200) Subject: One method to set netzone's relationship X-Git-Tag: v3.28~455^2~152 X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/commitdiff_plain/6dacf355bd5d72b9fb9da2eb229e441e626bd898 One method to set netzone's relationship A netzone is child of its parent, set_parent() is enough to determine the relationship parent/child of netzones. --- diff --git a/include/simgrid/kernel/routing/NetZoneImpl.hpp b/include/simgrid/kernel/routing/NetZoneImpl.hpp index c1bf111d43..d2eab40ff4 100644 --- a/include/simgrid/kernel/routing/NetZoneImpl.hpp +++ b/include/simgrid/kernel/routing/NetZoneImpl.hpp @@ -77,6 +77,7 @@ class XBT_PUBLIC NetZoneImpl : public xbt::PropertyHolder { std::shared_ptr host_model_; /** @brief Perform sealing procedure for derived classes, if necessary */ virtual void do_seal(){}; + void add_child(NetZoneImpl* new_zone); protected: explicit NetZoneImpl(const std::string& name); @@ -128,7 +129,6 @@ 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); /** @brief Retrieves the name of that netzone as a C++ string */ const std::string& get_name() const { return name_; } diff --git a/include/simgrid/s4u/NetZone.hpp b/include/simgrid/s4u/NetZone.hpp index 6ff7496f0b..dd4db0df25 100644 --- a/include/simgrid/s4u/NetZone.hpp +++ b/include/simgrid/s4u/NetZone.hpp @@ -56,7 +56,8 @@ public: void set_property(const std::string& key, const std::string& value); std::vector get_children() const; - NetZone* add_child(const NetZone* new_zone); + XBT_ATTRIB_DEPRECATED_v332("Please use set_parent() to manage NetZone's relationship") NetZone* add_child( + NetZone* new_zone); void extract_xbt_graph(const s_xbt_graph_t* graph, std::map>* nodes, std::map>* edges); diff --git a/src/kernel/routing/NetZoneImpl.cpp b/src/kernel/routing/NetZoneImpl.cpp index 9ce2ab479b..775009a199 100644 --- a/src/kernel/routing/NetZoneImpl.cpp +++ b/src/kernel/routing/NetZoneImpl.cpp @@ -487,8 +487,10 @@ void NetZoneImpl::set_parent(NetZoneImpl* parent) xbt_assert(not sealed_, "Impossible to set parent to an already sealed NetZone(%s)", this->get_cname()); parent_ = parent; netpoint_->set_englobing_zone(parent_); - /* copying models from parent host, to be reviewed when we allow multi-models */ if (parent) { + /* adding this class as child */ + parent->add_child(this); + /* copying models from parent host, to be reviewed when we allow multi-models */ set_network_model(parent->get_network_model()); set_cpu_pm_model(parent->get_cpu_pm_model()); set_cpu_vm_model(parent->get_cpu_vm_model()); diff --git a/src/s4u/s4u_Netzone.cpp b/src/s4u/s4u_Netzone.cpp index 7645d5d3fb..dc6f3d4d98 100644 --- a/src/s4u/s4u_Netzone.cpp +++ b/src/s4u/s4u_Netzone.cpp @@ -47,9 +47,9 @@ std::vector NetZone::get_children() const return res; } -NetZone* NetZone::add_child(const NetZone* new_zone) +NetZone* NetZone::add_child(NetZone* new_zone) { - pimpl_->add_child(new_zone->get_impl()); + new_zone->set_parent(this); return this; } diff --git a/src/surf/sg_platf.cpp b/src/surf/sg_platf.cpp index 12cc56a2a6..e256c36881 100644 --- a/src/surf/sg_platf.cpp +++ b/src/surf/sg_platf.cpp @@ -477,8 +477,6 @@ sg_platf_create_zone(const simgrid::kernel::routing::ZoneCreationArgs* zone) /* set the father behavior */ if (current_routing->hierarchy_ == simgrid::kernel::routing::NetZoneImpl::RoutingMode::unset) current_routing->hierarchy_ = simgrid::kernel::routing::NetZoneImpl::RoutingMode::recursive; - /* add to the sons dictionary */ - current_routing->add_child(new_zone); } return new_zone; }