// our content, as known to our graph routing algorithm (maps vertex_id -> vertex)
std::vector<kernel::routing::NetPoint*> vertices_;
- NetZoneImpl* father_ = nullptr;
+ NetZoneImpl* parent_ = nullptr;
std::vector<NetZoneImpl*> children_; // sub-netzones
std::string name_;
bool sealed_ = false; // We cannot add more content when sealed
s4u::NetZone* get_iface() { return &piface_; }
unsigned int get_table_size() const { return vertices_.size(); }
std::vector<kernel::routing::NetPoint*> get_vertices() const { return vertices_; }
- NetZoneImpl* get_father() const { return father_; }
+ XBT_ATTRIB_DEPRECATED_v331("Please use get_parent()") NetZoneImpl* get_father() const { return parent_; }
+ NetZoneImpl* get_parent() const { return parent_; }
/** @brief Returns the list of direct children (no grand-children). This returns the internal data, no copy.
* Don't mess with it.*/
std::vector<NetZoneImpl*>* get_children() { return &children_; }
+ void add_child(NetZoneImpl* new_zone) { children_.push_back(new_zone); }
+
/** @brief Retrieves the name of that netzone as a C++ string */
const std::string& get_name() const { return name_; }
/** @brief Retrieves the name of that netzone as a C string */
* s4u::Engine).
*/
class XBT_PUBLIC NetZone {
+ kernel::routing::NetZoneImpl* const pimpl_;
+
protected:
friend kernel::routing::NetZoneImpl;
/** @brief Retrieves the name of that netzone as a C string */
const char* get_cname() const;
- NetZone* get_father();
+ XBT_ATTRIB_DEPRECATED_v331("Please use get_parent()") NetZone* get_father();
+ NetZone* get_parent() const;
+ NetZone* set_parent(NetZone* parent);
std::vector<Host*> get_all_hosts() const;
int get_host_count() const;
kernel::routing::NetZoneImpl* get_impl() const { return pimpl_; }
-private:
- kernel::routing::NetZoneImpl* const pimpl_;
-
-public:
/** Get the properties assigned to a netzone */
const std::unordered_map<std::string, std::string>* get_properties() const;
/** Retrieve the property value (or nullptr if not set) */
void set_property(const std::string& key, const std::string& value);
std::vector<NetZone*> get_children() const;
+ NetZone* add_child(NetZone* new_zone);
+
void extract_xbt_graph(const s_xbt_graph_t* graph, std::map<std::string, xbt_node_t, std::less<>>* nodes,
std::map<std::string, xbt_edge_t, std::less<>>* edges);
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 */
void NetZoneImpl::set_parent(NetZoneImpl* parent)
{
xbt_assert(sealed_ == false, "Impossible to set parent to an already sealed NetZone(%s)", this->get_cname());
- father_ = parent;
- netpoint_->set_englobing_zone(father_);
+ parent_ = parent;
+ netpoint_->set_englobing_zone(parent_);
}
void NetZoneImpl::set_network_model(std::shared_ptr<resource::NetworkModel> netmodel)
return res;
}
+NetZone* NetZone::add_child(NetZone* new_zone)
+{
+ pimpl_->add_child(new_zone->get_impl());
+ return this;
+}
+
const std::string& NetZone::get_name() const
{
return pimpl_->get_name();
}
+
const char* NetZone::get_cname() const
{
return pimpl_->get_cname();
}
+
NetZone* NetZone::get_father()
{
- return pimpl_->get_father()->get_iface();
+ return pimpl_->get_parent()->get_iface();
+}
+
+NetZone* NetZone::get_parent() const
+{
+ return pimpl_->get_parent()->get_iface();
+}
+
+NetZone* NetZone::set_parent(NetZone* parent)
+{
+ pimpl_->set_parent(parent->get_impl());
+ return this;
}
/** @brief Returns the list of the hosts found in this NetZone (not recursively)
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->get_children()->push_back(new_zone);
+ current_routing->add_child(new_zone);
/* set models from parent netzone */
new_zone->set_network_model(current_routing->get_network_model());
new_zone->set_cpu_pm_model(current_routing->get_cpu_pm_model());
xbt_assert(current_routing, "Cannot seal the current Zone: zone under construction");
current_routing->seal();
simgrid::s4u::NetZone::on_seal(*current_routing->get_iface());
- current_routing = current_routing->get_father();
+ current_routing = current_routing->get_parent();
}
/** @brief Add a link connecting a host to the rest of its Zone (which must be cluster or vivaldi) */