Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
rename As::getRouteAndLatency into As::getLocalRoute
[simgrid.git] / src / kernel / routing / AsRoutedGraph.cpp
index a574eca..8dc559f 100644 (file)
@@ -30,8 +30,6 @@ AsRoutedGraph::AsRoutedGraph(As* father, const char* name) : AsImpl(father, name
 {
 }
 
-AsRoutedGraph::~AsRoutedGraph()=default;
-
 }}} // namespace simgrid::kernel::routing
 
 /* ************************************************************************** */
@@ -81,35 +79,34 @@ namespace simgrid {
 namespace kernel {
 namespace routing {
 
-  xbt_dynar_t AsRoutedGraph::getOneLinkRoutes()
-  {
-    xbt_dynar_t ret = xbt_dynar_new(sizeof(Onelink*), xbt_free_f);
-    sg_platf_route_cbarg_t route = xbt_new0(s_sg_platf_route_cbarg_t,1);
-    route->link_list = new std::vector<Link*>();
-
-    int table_size = static_cast<int>(vertices_.size());
-    for(int src=0; src < table_size; src++) {
-      for(int dst=0; dst< table_size; dst++) {
-        route->link_list->clear();
-        NetCard *src_elm = vertices_.at(src);
-        NetCard *dst_elm = vertices_.at(dst);
-        this->getRouteAndLatency(src_elm, dst_elm,route, nullptr);
-
-        if (route->link_list->size() == 1) {
-          Link *link = route->link_list->at(0);
-          Onelink *onelink;
-          if (hierarchy_ == RoutingMode::base)
-            onelink = new Onelink(link, src_elm, dst_elm);
-          else if (hierarchy_ == RoutingMode::recursive)
-            onelink = new Onelink(link, route->gw_src, route->gw_dst);
-          else
-            onelink = new Onelink(link, nullptr, nullptr);
-          xbt_dynar_push(ret, &onelink);
-        }
+void AsRoutedGraph::getOneLinkRoutes(std::vector<Onelink*>* accumulator)
+{
+  sg_platf_route_cbarg_t route = xbt_new0(s_sg_platf_route_cbarg_t, 1);
+  route->link_list             = new std::vector<Link*>();
+
+  int table_size = static_cast<int>(vertices_.size());
+  for (int src = 0; src < table_size; src++) {
+    for (int dst = 0; dst < table_size; dst++) {
+      route->link_list->clear();
+      NetCard* src_elm = vertices_.at(src);
+      NetCard* dst_elm = vertices_.at(dst);
+      this->getLocalRoute(src_elm, dst_elm, route, nullptr);
+
+      if (route->link_list->size() == 1) {
+        Link* link = route->link_list->at(0);
+        Onelink* onelink;
+        if (hierarchy_ == RoutingMode::base)
+          onelink = new Onelink(link, src_elm, dst_elm);
+        else if (hierarchy_ == RoutingMode::recursive)
+          onelink = new Onelink(link, route->gw_src, route->gw_dst);
+        else
+          onelink = new Onelink(link, nullptr, nullptr);
+        accumulator->push_back(onelink);
       }
     }
-    return ret;
   }
+  AsImpl::getOneLinkRoutes(accumulator); // Recursivly call this function on all my childs too
+}
 
 void AsRoutedGraph::getGraph(xbt_graph_t graph, xbt_dict_t nodes, xbt_dict_t edges)
 {
@@ -121,7 +118,7 @@ void AsRoutedGraph::getGraph(xbt_graph_t graph, xbt_dict_t nodes, xbt_dict_t edg
       sg_platf_route_cbarg_t route = xbt_new0(s_sg_platf_route_cbarg_t, 1);
       route->link_list = new std::vector<Link*>();
 
-      getRouteAndLatency(my_src, my_dst, route, nullptr);
+      getLocalRoute(my_src, my_dst, route, nullptr);
 
       XBT_DEBUG("get_route_and_latency %s -> %s", my_src->name().c_str(), my_dst->name().c_str());