Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
cleanup in the Link field names
[simgrid.git] / src / kernel / routing / AsFloyd.cpp
index eb4c8ad..04b9536 100644 (file)
@@ -3,8 +3,9 @@
 /* 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 <limits>
+
 #include "xbt/log.h"
-#include "xbt/dynar.h"
 #include "src/kernel/routing/AsFloyd.hpp"
 #include "src/surf/network_interface.hpp"
 
@@ -18,8 +19,7 @@ namespace simgrid {
 namespace kernel {
 namespace routing {
 
-AsFloyd::AsFloyd(const char*name)
-  : AsRoutedGraph(name)
+AsFloyd::AsFloyd(As* father, const char* name) : AsRoutedGraph(father, name)
 {
   predecessorTable_ = nullptr;
   costTable_ = nullptr;
@@ -27,9 +27,9 @@ AsFloyd::AsFloyd(const char*name)
 }
 
 AsFloyd::~AsFloyd(){
-  int table_size = static_cast<int>(vertices_.size());
   if (linkTable_ == nullptr) // Dealing with a parse error in the file?
     return;
+  int table_size = vertices_.size();
   /* Delete link_table */
   for (int i = 0; i < table_size; i++)
     for (int j = 0; j < table_size; j++)
@@ -47,26 +47,26 @@ void AsFloyd::getRouteAndLatency(NetCard *src, NetCard *dst, sg_platf_route_cbar
   getRouteCheckParams(src, dst);
 
   /* create a result route */
-  xbt_dynar_t route_stack = xbt_dynar_new(sizeof(sg_platf_route_cbarg_t), nullptr);
+  std::vector<sg_platf_route_cbarg_t> route_stack;
   int pred;
   unsigned int cur = dst->id();
   do {
     pred = TO_FLOYD_PRED(src->id(), cur);
     if (pred == -1)
       THROWF(arg_error, 0, "No route from '%s' to '%s'", src->name(), dst->name());
-    xbt_dynar_push_as(route_stack, sg_platf_route_cbarg_t, TO_FLOYD_LINK(pred, cur));
+    route_stack.push_back(TO_FLOYD_LINK(pred, cur));
     cur = pred;
   } while (cur != src->id());
 
   if (hierarchy_ == RoutingMode::recursive) {
-    route->gw_src = xbt_dynar_getlast_as(route_stack, sg_platf_route_cbarg_t)->gw_src;
-    route->gw_dst = xbt_dynar_getfirst_as(route_stack, sg_platf_route_cbarg_t)->gw_dst;
+    route->gw_src = route_stack.back()->gw_src;
+    route->gw_dst = route_stack.front()->gw_dst;
   }
 
   sg_netcard_t prev_dst_gw = nullptr;
-  while (!xbt_dynar_is_empty(route_stack)) {
-    sg_platf_route_cbarg_t e_route = xbt_dynar_pop_as(route_stack, sg_platf_route_cbarg_t);
-
+  while (!route_stack.empty()) {
+    sg_platf_route_cbarg_t e_route = route_stack.back();
+    route_stack.pop_back();
     if (hierarchy_ == RoutingMode::recursive && prev_dst_gw != nullptr && strcmp(prev_dst_gw->name(), e_route->gw_src->name())) {
       routing_platf->getRouteAndLatency(prev_dst_gw, e_route->gw_src, route->link_list, lat);
     }
@@ -74,12 +74,11 @@ void AsFloyd::getRouteAndLatency(NetCard *src, NetCard *dst, sg_platf_route_cbar
     for (auto link: *e_route->link_list) {
       route->link_list->push_back(link);
       if (lat)
-        *lat += link->getLatency();
+        *lat += link->latency();
     }
 
     prev_dst_gw = e_route->gw_dst;
   }
-  xbt_dynar_free(&route_stack);
 }
 
 void AsFloyd::addRoute(sg_platf_route_cbarg_t route)