Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Fix some doxygen errors
[simgrid.git] / src / kernel / routing / ClusterZone.cpp
index 6cb35754688572e2d320e13448dddc568a5e9f09..fa82dd48d0c6776781f8d78a6d37075a9305be25 100644 (file)
@@ -1,21 +1,19 @@
-/* Copyright (c) 2009-2021. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2009-2023. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
 
+#include "simgrid/s4u/Host.hpp"
 #include "simgrid/kernel/routing/ClusterZone.hpp"
 #include "simgrid/kernel/routing/NetPoint.hpp"
-#include "simgrid/kernel/routing/RoutedZone.hpp"
-#include "src/surf/network_interface.hpp"
+#include "src/kernel/resource/StandardLinkImpl.hpp"
 
-XBT_LOG_NEW_DEFAULT_SUBCATEGORY(surf_route_cluster, surf, "Routing part of surf");
+XBT_LOG_NEW_DEFAULT_SUBCATEGORY(ker_routing_cluster, ker_platform, "Kernel Cluster Routing");
 
 /* This routing is specifically setup to represent clusters, aka homogeneous sets of machines
  * Note that a router is created, easing the interconnection with the rest of the world. */
 
-namespace simgrid {
-namespace kernel {
-namespace routing {
+namespace simgrid::kernel::routing {
 
 void ClusterBase::set_loopback()
 {
@@ -40,26 +38,23 @@ void ClusterBase::set_link_characteristics(double bw, double lat, s4u::Link::Sha
   link_lat_            = lat;
 }
 
-void ClusterBase::add_private_link_at(unsigned int position, std::pair<resource::LinkImpl*, resource::LinkImpl*> link)
+void ClusterBase::add_private_link_at(unsigned long position,
+                                      std::pair<resource::StandardLinkImpl*, resource::StandardLinkImpl*> link)
 {
-  private_links_.insert({position, link});
+  private_links_.try_emplace(position, link);
 }
 
-void ClusterBase::set_gateway(unsigned int position, NetPoint* gateway)
+void ClusterBase::set_gateway(unsigned long position, NetPoint* gateway)
 {
   xbt_assert(not gateway || not gateway->is_netzone(), "ClusterBase: gateway cannot be another netzone %s",
              gateway->get_cname());
   gateways_[position] = gateway;
 }
 
-NetPoint* ClusterBase::get_gateway(unsigned int position)
+NetPoint* ClusterBase::get_gateway(unsigned long position)
 {
-  NetPoint* res = nullptr;
-  auto it       = gateways_.find(position);
-  if (it != gateways_.end()) {
-    res = it->second;
-  }
-  return res;
+  auto it = gateways_.find(position);
+  return it == gateways_.end() ? nullptr : it->second;
 }
 
 void ClusterBase::fill_leaf_from_cb(unsigned long position, const std::vector<unsigned long>& dimensions,
@@ -73,13 +68,12 @@ void ClusterBase::fill_leaf_from_cb(unsigned long position, const std::vector<un
   *limiter_link = nullptr;
 
   // auxiliary function to get dims from index
-  auto index_to_dims = [&dimensions](int index) {
-    std::vector<unsigned int> dims_array(dimensions.size());
+  auto index_to_dims = [&dimensions](unsigned long index) {
+    std::vector<unsigned long> dims_array(dimensions.size());
     for (auto i = static_cast<int>(dimensions.size() - 1); i >= 0; --i) {
-      if (index <= 0) {
+      if (index == 0)
         break;
-      }
-      unsigned int value = index % dimensions[i];
+      unsigned long value = index % dimensions[i];
       dims_array[i]      = value;
       index              = (index / dimensions[i]);
     }
@@ -89,7 +83,17 @@ void ClusterBase::fill_leaf_from_cb(unsigned long position, const std::vector<un
   kernel::routing::NetPoint* netpoint = nullptr;
   kernel::routing::NetPoint* gw       = nullptr;
   auto dims                           = index_to_dims(position);
-  std::tie(netpoint, gw)              = set_callbacks.netpoint(get_iface(), dims, position);
+  if (set_callbacks.is_by_netpoint()) { // XBT_ATTRIB_DEPRECATED_v339
+    std::tie(netpoint, gw) = set_callbacks.netpoint(get_iface(), dims, position); // XBT_ATTRIB_DEPRECATED_v339
+  } else if (set_callbacks.is_by_netzone()) {
+    s4u::NetZone* netzone = set_callbacks.netzone(get_iface(), dims, position);
+    netpoint              = netzone->get_netpoint();
+    gw                    = netzone->get_gateway();
+  } else {
+    s4u::Host* host = set_callbacks.host(get_iface(), dims, position);
+    netpoint        = host->get_netpoint();
+  }
+
   xbt_assert(netpoint, "set_netpoint(elem=%lu): Invalid netpoint (nullptr)", position);
   if (netpoint->is_netzone()) {
     xbt_assert(gw && not gw->is_netzone(),
@@ -119,6 +123,4 @@ void ClusterBase::fill_leaf_from_cb(unsigned long position, const std::vector<un
   *node_netpoint = netpoint;
 }
 
-} // namespace routing
-} // namespace kernel
-} // namespace simgrid
+} // namespace simgrid::kernel::routing