/* 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"
#define TO_FLOYD_LINK(i,j) (linkTable_)[(i)+(j)*table_size]
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;
}
AsFloyd::~AsFloyd(){
- int table_size = static_cast<int>(xbt_dynar_length(vertices_));
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++)
void AsFloyd::getRouteAndLatency(NetCard *src, NetCard *dst, sg_platf_route_cbarg_t route, double *lat)
{
- size_t table_size = xbt_dynar_length(vertices_);
+ size_t table_size = vertices_.size();
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;
- int cur = dst->id();
+ 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);
}
prev_dst_gw = e_route->gw_dst;
}
- xbt_dynar_free(&route_stack);
}
void AsFloyd::addRoute(sg_platf_route_cbarg_t route)
{
/* set the size of table routing */
- int table_size = static_cast<int>(xbt_dynar_length(vertices_));
+ int table_size = static_cast<int>(vertices_.size());
addRouteCheckParams(route);
}
void AsFloyd::seal(){
-
/* set the size of table routing */
- size_t table_size = xbt_dynar_length(vertices_);
+ size_t table_size = vertices_.size();
if(!linkTable_) {
/* Create Cost, Predecessor and Link tables */
}
}
-}
-}
+}}}