XBT_LOG_NEW_DEFAULT_SUBCATEGORY(ker_routing, kernel, "Kernel routing-related information");
-namespace simgrid {
-namespace kernel {
-namespace routing {
+namespace simgrid::kernel::routing {
/* Pick the right models for CPU, net and host, and call their model_init_preparse */
static void surf_config_models_setup()
s4u::Engine::get_instance()->netpoint_unregister(netpoint_);
}
+xbt_node_t NetZoneImpl::new_xbt_graph_node(const s_xbt_graph_t* graph, const char* name,
+ std::map<std::string, xbt_node_t, std::less<>>* nodes)
+{
+ auto [elm, inserted] = nodes->try_emplace(name);
+ if (inserted)
+ elm->second = xbt_graph_new_node(graph, xbt_strdup(name));
+ return elm->second;
+}
+
+xbt_edge_t NetZoneImpl::new_xbt_graph_edge(const s_xbt_graph_t* graph, xbt_node_t src, xbt_node_t dst,
+ std::map<std::string, xbt_edge_t, std::less<>>* edges)
+{
+ const auto* src_name = static_cast<const char*>(xbt_graph_node_get_data(src));
+ const auto* dst_name = static_cast<const char*>(xbt_graph_node_get_data(dst));
+
+ auto elm = edges->find(std::string(src_name) + dst_name);
+ if (elm == edges->end()) {
+ bool inserted;
+ std::tie(elm, inserted) = edges->try_emplace(std::string(dst_name) + src_name);
+ if (inserted)
+ elm->second = xbt_graph_new_edge(graph, src, dst, nullptr);
+ }
+
+ return elm->second;
+}
+
void NetZoneImpl::add_child(NetZoneImpl* new_zone)
{
xbt_assert(not sealed_, "Cannot add a new child to the sealed zone %s", get_cname());
resource::StandardLinkImpl* NetZoneImpl::get_link_by_name_or_null(const std::string& name) const
{
- auto link_it = links_.find(name);
- if (link_it != links_.end())
+ if (auto link_it = links_.find(name); link_it != links_.end())
return link_it->second;
for (const auto* child : children_) {
resource::SplitDuplexLinkImpl* NetZoneImpl::get_split_duplex_link_by_name_or_null(const std::string& name) const
{
- auto link_it = split_duplex_links_.find(name);
- if (link_it != split_duplex_links_.end())
+ if (auto link_it = split_duplex_links_.find(name); link_it != split_duplex_links_.end())
return link_it->second.get();
for (const auto* child : children_) {
return std::any_of(begin(children_), end(children_),
[netpoint](const auto* child) { return child->is_component_recursive(netpoint); });
}
-} // namespace routing
-} // namespace kernel
-} // namespace simgrid
+} // namespace simgrid::kernel::routing